!! This File contains subroutines that look redundant
!! but it is important that they remain inside their individual modules.

!#########################################################################
MODULE WSU_TYPEDEF
implicit none
private
public :: UVCOR ,uvco 

TYPE UVCOR
 sequence
!INPUTS 
 real swdn_b5		!! Uncorrected SFC SWdn Fu band5 (0.2985-0.3225) partial UVB
 real swdn_b6		!! Uncorrected SFC SWdn Fu band6 (0.3225-0.3575) partial UVA

 real o3		!! O3 DU  (200-600)
 real u0		!! Cosine Sol (0-1.0)
 real salb		!! UV  Albedo (0-1) (0.2985-0.3225)
 real p03_20km	!! Percent O3 Below 10mb
 real tauabs		!! Aerosol Absorption optical depth of band_6 =AOT_band6*(1-ssa)

 real cldtau  !Cldtau 1-99..
 real cldhgt  !CldHgt (km)
!OUTPUTS
  real cr_uva  ! Correction ratio ( SBDART_UVA / Fuband6)
  real uva	 !! Derived UVA Sfc Dn  !UV-A (.32-.40 )

  real cr_uvb  ! Correction ratio ( SBDART_UVB / Fuband5)
  real uvb	 !! Derived UVB Sfc Dn   !!!UV-B(0.29-0.32)

  real cr_ery  ! Correction ratio ( SBDART_UVB / Fuband5)
  real ery	 !! Derived ERY Sfc Dn
  real uvi     !! UV-INDEX (0-15)
END TYPE UVCOR
TYPE (UVCOR) uvco
END MODULE WSU_TYPEDEF

!#########################################################################

MODULE UVB_CORRECTION
USE WSU_TYPEDEF ,only : uvco
implicit none
private
public ::  uvco,uvb_lut

integer ,parameter :: nv = 3  ,mxn =7 
! nv = # of Variables in look up table.
! mxn = Max # of nodes for any single variable
! nva = # of nodes for each variables
! anodes = The values at each node in the table; for all variables
 
integer nva(nv)
real,save:: anodes(mxn,nv)
logical ,save:: ichoose(nv,2**nv), uvinit = .false.

data nva  /7,2,2/

!1-7 sza
data anodes(1:7,1) /  0. , 10. , 20. , 30. , 40. , 50. , 60./
!! 1-2 Sfcalb in band 5
data anodes(1:2,2) /0.1,0.9/
!! 1-2 Percent O3 Below 20km

data anodes(1:5,3) /40., 59., 65.  ,68. ,72.0/ 

!---------------------------
real ,dimension(0:5,70) :: cuvb
  data cuvb / & ! 7 sza , 2 sfcalb , 5 o3profileindex !V2
  0.1382E+03,  0.3720E+00, -0.5015E-03,  0.9923E-07,  0.2393E-09, -0.2988E-12,  &
  0.1392E+03,  0.3720E+00, -0.5045E-03,  0.1057E-06,  0.2264E-09, -0.2964E-12,  &
  0.1421E+03,  0.3691E+00, -0.5062E-03,  0.1162E-06,  0.1836E-09, -0.2845E-12,  &
  0.1472E+03,  0.3644E+00, -0.5157E-03,  0.1456E-06,  0.1008E-09, -0.2608E-12,  &
  0.1555E+03,  0.3573E+00, -0.5410E-03,  0.2085E-06, -0.4151E-10, -0.2145E-12,  &
  0.1675E+03,  0.3444E+00, -0.5995E-03,  0.3311E-06, -0.2744E-09, -0.1171E-12,  &
  0.1846E+03,  0.3326E+00, -0.7750E-03,  0.6359E-06, -0.6906E-09,  0.1484E-12,  &
  0.1382E+03,  0.3720E+00, -0.5015E-03,  0.9923E-07,  0.2393E-09, -0.2988E-12,  &
  0.1392E+03,  0.3720E+00, -0.5045E-03,  0.1057E-06,  0.2264E-09, -0.2964E-12,  &
  0.1421E+03,  0.3691E+00, -0.5062E-03,  0.1162E-06,  0.1836E-09, -0.2845E-12,  &
  0.1472E+03,  0.3644E+00, -0.5157E-03,  0.1456E-06,  0.1008E-09, -0.2608E-12,  &
  0.1555E+03,  0.3573E+00, -0.5410E-03,  0.2085E-06, -0.4151E-10, -0.2145E-12,  &
  0.1675E+03,  0.3444E+00, -0.5995E-03,  0.3311E-06, -0.2744E-09, -0.1171E-12,  &
  0.1846E+03,  0.3326E+00, -0.7750E-03,  0.6359E-06, -0.6906E-09,  0.1484E-12,  &
  0.1387E+03,  0.3736E+00, -0.5009E-03,  0.9536E-07,  0.2386E-09, -0.2969E-12,  &
  0.1396E+03,  0.3740E+00, -0.5055E-03,  0.1036E-06,  0.2268E-09, -0.2960E-12,  &
  0.1425E+03,  0.3711E+00, -0.5062E-03,  0.1125E-06,  0.1833E-09, -0.2830E-12,  &
  0.1476E+03,  0.3681E+00, -0.5206E-03,  0.1461E-06,  0.1026E-09, -0.2625E-12,  &
  0.1560E+03,  0.3613E+00, -0.5454E-03,  0.2070E-06, -0.4037E-10, -0.2146E-12,  &
  0.1681E+03,  0.3498E+00, -0.6074E-03,  0.3318E-06, -0.2738E-09, -0.1171E-12,  &
  0.1850E+03,  0.3410E+00, -0.7961E-03,  0.6501E-06, -0.6924E-09,  0.1483E-12,  &
  0.1387E+03,  0.3736E+00, -0.5009E-03,  0.9536E-07,  0.2386E-09, -0.2969E-12,  &
  0.1396E+03,  0.3740E+00, -0.5055E-03,  0.1036E-06,  0.2268E-09, -0.2960E-12,  &
  0.1425E+03,  0.3711E+00, -0.5062E-03,  0.1125E-06,  0.1833E-09, -0.2830E-12,  &
  0.1476E+03,  0.3681E+00, -0.5206E-03,  0.1461E-06,  0.1026E-09, -0.2625E-12,  &
  0.1560E+03,  0.3613E+00, -0.5454E-03,  0.2070E-06, -0.4037E-10, -0.2146E-12,  &
  0.1681E+03,  0.3498E+00, -0.6074E-03,  0.3318E-06, -0.2738E-09, -0.1171E-12,  &
  0.1850E+03,  0.3410E+00, -0.7961E-03,  0.6501E-06, -0.6924E-09,  0.1483E-12,  &
  0.1383E+03,  0.3717E+00, -0.5102E-03,  0.1026E-06,  0.2460E-09, -0.3007E-12,  &
  0.1393E+03,  0.3712E+00, -0.5121E-03,  0.1085E-06,  0.2323E-09, -0.2974E-12,  &
  0.1421E+03,  0.3694E+00, -0.5174E-03,  0.1221E-06,  0.1915E-09, -0.2877E-12,  &
  0.1473E+03,  0.3654E+00, -0.5305E-03,  0.1555E-06,  0.1094E-09, -0.2654E-12,  &
  0.1557E+03,  0.3573E+00, -0.5531E-03,  0.2149E-06, -0.3455E-10, -0.2148E-12,  &
  0.1678E+03,  0.3454E+00, -0.6185E-03,  0.3465E-06, -0.2696E-09, -0.1173E-12,  &
  0.1850E+03,  0.3340E+00, -0.8010E-03,  0.6563E-06, -0.6784E-09,  0.1443E-12,  &
  0.1369E+03,  0.3637E+00, -0.5182E-03,  0.1491E-06,  0.1803E-09, -0.2656E-12,  &
  0.1377E+03,  0.3648E+00, -0.5259E-03,  0.1601E-06,  0.1699E-09, -0.2663E-12,  &
  0.1406E+03,  0.3623E+00, -0.5297E-03,  0.1738E-06,  0.1275E-09, -0.2540E-12,  &
  0.1457E+03,  0.3581E+00, -0.5424E-03,  0.2066E-06,  0.4666E-10, -0.2295E-12,  &
  0.1535E+03,  0.3506E+00, -0.5696E-03,  0.2691E-06, -0.9156E-10, -0.1793E-12,  &
  0.1654E+03,  0.3387E+00, -0.6314E-03,  0.3909E-06, -0.3137E-09, -0.7816E-13,  &
  0.1815E+03,  0.3315E+00, -0.8331E-03,  0.7269E-06, -0.7280E-09,  0.1991E-12,  &
  0.1383E+03,  0.3747E+00, -0.5053E-03,  0.9868E-07,  0.2420E-09, -0.2998E-12,  &
  0.1393E+03,  0.3736E+00, -0.5043E-03,  0.1010E-06,  0.2264E-09, -0.2938E-12,  &
  0.1421E+03,  0.3731E+00, -0.5138E-03,  0.1188E-06,  0.1881E-09, -0.2880E-12,  &
  0.1473E+03,  0.3691E+00, -0.5246E-03,  0.1490E-06,  0.1048E-09, -0.2642E-12,  &
  0.1557E+03,  0.3623E+00, -0.5494E-03,  0.2100E-06, -0.3888E-10, -0.2155E-12,  &
  0.1677E+03,  0.3527E+00, -0.6196E-03,  0.3475E-06, -0.2774E-09, -0.1197E-12,  &
  0.1850E+03,  0.3440E+00, -0.8074E-03,  0.6643E-06, -0.6992E-09,  0.1493E-12,  &
  0.1370E+03,  0.3708E+00, -0.5166E-03,  0.1454E-06,  0.1777E-09, -0.2671E-12,  &
  0.1380E+03,  0.3697E+00, -0.5163E-03,  0.1480E-06,  0.1634E-09, -0.2618E-12,  &
  0.1407E+03,  0.3681E+00, -0.5218E-03,  0.1625E-06,  0.1221E-09, -0.2508E-12,  &
  0.1456E+03,  0.3663E+00, -0.5404E-03,  0.2008E-06,  0.4286E-10, -0.2304E-12,  &
  0.1535E+03,  0.3587E+00, -0.5649E-03,  0.2594E-06, -0.9638E-10, -0.1793E-12,  &
  0.1653E+03,  0.3500E+00, -0.6337E-03,  0.3883E-06, -0.3223E-09, -0.7972E-13,  &
  0.1814E+03,  0.3460E+00, -0.8394E-03,  0.7256E-06, -0.7456E-09,  0.2056E-12,  &
  0.1375E+03,  0.3708E+00, -0.5150E-03,  0.1064E-06,  0.2501E-09, -0.3025E-12,  &
  0.1386E+03,  0.3708E+00, -0.5183E-03,  0.1133E-06,  0.2373E-09, -0.3002E-12,  &
  0.1414E+03,  0.3687E+00, -0.5237E-03,  0.1279E-06,  0.1962E-09, -0.2907E-12,  &
  0.1466E+03,  0.3644E+00, -0.5366E-03,  0.1617E-06,  0.1136E-09, -0.2677E-12,  &
  0.1551E+03,  0.3556E+00, -0.5589E-03,  0.2218E-06, -0.3127E-10, -0.2160E-12,  &
  0.1674E+03,  0.3431E+00, -0.6235E-03,  0.3546E-06, -0.2679E-09, -0.1176E-12,  &
  0.1849E+03,  0.3307E+00, -0.8032E-03,  0.6622E-06, -0.6758E-09,  0.1433E-12,  &
  0.1357E+03,  0.3642E+00, -0.5313E-03,  0.1611E-06,  0.1886E-09, -0.2725E-12,  &
  0.1365E+03,  0.3644E+00, -0.5368E-03,  0.1706E-06,  0.1769E-09, -0.2717E-12,  &
  0.1394E+03,  0.3616E+00, -0.5398E-03,  0.1833E-06,  0.1337E-09, -0.2580E-12,  &
  0.1444E+03,  0.3577E+00, -0.5550E-03,  0.2202E-06,  0.5245E-10, -0.2345E-12,  &
  0.1525E+03,  0.3490E+00, -0.5808E-03,  0.2842E-06, -0.8865E-10, -0.1825E-12,  &
  0.1645E+03,  0.3354E+00, -0.6382E-03,  0.4025E-06, -0.3121E-09, -0.7831E-13,  &
  0.1809E+03,  0.3274E+00, -0.8358E-03,  0.7352E-06, -0.7249E-09,  0.1971E-12   /


contains
!------------------------------------------------------------------------
	subroutine tf_table(n1,n2,ib)
	implicit none
	integer n1,n2,i,ii
	logical ib(n1,n2)
	if(  uvinit ) return
	do i=1,n2
	do ii=1,n1
	ib(ii,i)=btest(i-1,ii-1)
	enddo
!	print*,i,ib(1:n1,i)
	enddo
	uvinit = .true.
	return
	end subroutine tf_table
!-----------------------------------------------------------------------
	integer function ilui(iva)
	implicit none
	integer i,k
	integer  iva(nv)
	integer  mva(nv)

	mva(1)=nva(1)
	do i=2,nv
	 mva(i)=mva(i-1)*nva(i)
	enddo

	k= iva(1)
	do i=2,nv
	k= k+ (iva(i)-1)*mva(i-1)
	enddo

	ilui=k
	return
	end function ilui
!----------------------------------------------------------------
subroutine uvb_lut
implicit none

	real B_vt, swx,wx,rmin,rmax,B_value
	integer i,j,ik,k,iv,in
	integer  iva(nv,2**nv)
	
	real wb(nv),wt(nv),rva(nv),val(nv)
	integer ibase(nv),itop(nv)
	real o3x(5)

	o3x(1)=uvco%o3
	do i=2,5
	 o3x(i) = o3x(i-1)*o3x(1)
 	enddo


	val(1) =  acos(uvco%u0) *(180.0/3.14159)	! Cos Sol to SZA
	val(2) =  uvco%salb		! Spectral Surface Albedo in UV
	val(3) =  uvco%p03_20km	! % O3 below 20km
	
	 call tf_table(nv,2**nv,ichoose)
!--------------------
	 VSET : do iv=1,nv 
	rmin = anodes(1,iv)
	rmax = anodes(nva(iv),iv)

	if (val(iv) <= rmin )then 
	  rva(iv) = 1
	elseif (val(iv) >= rmax ) then
	  rva(iv) = nva(iv)
	else

	FNODES : do in = 1,nva(iv)-1
	if( val(iv) >= anodes(in,iv) .and. val(iv) < anodes(in+1,iv)) & 
     	rva(iv)= in+( val(iv)-anodes(in,iv)) /                        &
                    (anodes(in+1,iv)-anodes(in,iv))
	enddo FNODES

	endif

!	print*,iv,rva(iv)
	enddo VSET
!---------------------

	 ibase = floor(rva)
	 where( ibase < 1) ibase=1

	 itop= ceiling(rva)
	 where( itop > nva) itop=nva

	wb=1.0-(rva-ibase)
	wt=1.0-wb
	
!	print'(A10,10f5.1)','Exact',rva(1:nv)
!	print'(A10,10I5)','BASE',ibase
!	print'(A10,10I5)','TOP',itop
!	print'(A10,10f5.1)','Wb',wb	
!	print'(A10,10f5.1)','Wt',wt

	swx=0 ;  B_value =0 ; ik=0

	NODE : do j=1,2**nv
	wx=1.0

	 DIMENSION: do i=1,nv

	 if( ichoose(i,j) ) then
	  iva(i,j) = itop(i)
	  wx=wx*wt(i)
	 else
	  iva(i,j) = ibase(i)
	  wx=wx*wb(i)
	 endif

	 enddo DIMENSION

	 if( wx > 0 ) then
	 ik=ik+1
	 k = ilui(iva(1,j))

	 B_vt  = cuvb(0,k) + &
		  cuvb(1,k)*o3x(1) + cuvb(2,k)*o3x(2) + &
		  cuvb(3,k)*o3x(3) + cuvb(4,k)*o3x(4)+ cuvb(5,k)*o3x(5)!UVB
	 swx       = swx  +               wx

	 B_value      = B_value + B_vt * wx

!	print'(2I4,i10,4f10.5,10I4)',ik,j,k, A_vt,B_vt ,wx,swx,iva(1:nv,j)
!	if (swx >= 0.9999 )exit
	endif

	enddo NODE
    
	uvco%cr_uvb = 100. / (B_value/swx)	    
	uvco%uvb = uvco%swdn_b5 * uvco%cr_uvb
	
	return

	end subroutine uvb_lut

END MODULE UVB_CORRECTION
!##########################################################################
MODULE UVA_CORRECTION
USE WSU_TYPEDEF ,only : uvco
implicit none
private
public ::  uvco,uva_lut

integer ,parameter :: nv = 3  ,mxn =7 
! nv = # of Variables in look up table.
! mxn = Max # of nodes for any single variable
! nva = # of nodes for each variables
! anodes = The values at each node in the table; for all variables
 
integer nva(nv)
real,save:: anodes(mxn,nv)
logical ,save:: ichoose(nv,2**nv), uvinit = .false.

data nva  /7,2,2/

!1-7 sza
data anodes(1:7,1) /  0. , 10. , 20. , 30. , 40. , 50. , 60./
!! 1-2 band6 ABS TAU = Tau*(1-ssa)
data anodes(1:2,2) /0.007,0.110/
!! 1-2 Sfcalb in band 6
data anodes(1:2,3) /0.1,0.9/


!---------------------------

real ,dimension(28)   :: cuva
real ,dimension(0:3,28)  :: cery !!!( repeated 4time to keep same wt fct.)

  data cuva / & ! 7 sza , 2 aerosol index , 2 sfcalbedo
  36.997,  36.970,  36.889,  36.745,  36.522,  36.195,  35.748,  &
  35.968,  35.935,  35.836,  35.671,  35.441,  35.177,  34.990,  &
  38.924,  38.898,  38.820,  38.678,  38.458,  38.134,  37.677,  &
  36.818,  36.786,  36.688,  36.524,  36.294,  36.031,  35.847/
  data cery / & ! 3rdOrd Poly  7 sza 
  0.3124E+02, -0.1223E+00,  0.2750E-03, -0.2178E-06,  &
  0.3096E+02, -0.1212E+00,  0.2735E-03, -0.2167E-06,  &
  0.3009E+02, -0.1178E+00,  0.2681E-03, -0.2123E-06,  &
  0.2861E+02, -0.1118E+00,  0.2588E-03, -0.2048E-06,  &
  0.2642E+02, -0.1020E+00,  0.2422E-03, -0.1902E-06,  &
  0.2356E+02, -0.8818E-01,  0.2182E-03, -0.1665E-06,  &
  0.1999E+02, -0.6889E-01,  0.1839E-03, -0.1255E-06,  &
  0.3124E+02, -0.1223E+00,  0.2750E-03, -0.2178E-06,  &
  0.3096E+02, -0.1212E+00,  0.2735E-03, -0.2167E-06,  &
  0.3009E+02, -0.1178E+00,  0.2681E-03, -0.2123E-06,  &
  0.2861E+02, -0.1118E+00,  0.2588E-03, -0.2048E-06,  &
  0.2642E+02, -0.1020E+00,  0.2422E-03, -0.1902E-06,  &
  0.2356E+02, -0.8818E-01,  0.2182E-03, -0.1665E-06,  &
  0.1999E+02, -0.6889E-01,  0.1839E-03, -0.1255E-06,  &   
  0.3124E+02, -0.1223E+00,  0.2750E-03, -0.2178E-06,  &
  0.3096E+02, -0.1212E+00,  0.2735E-03, -0.2167E-06,  &
  0.3009E+02, -0.1178E+00,  0.2681E-03, -0.2123E-06,  &
  0.2861E+02, -0.1118E+00,  0.2588E-03, -0.2048E-06,  &
  0.2642E+02, -0.1020E+00,  0.2422E-03, -0.1902E-06,  &
  0.2356E+02, -0.8818E-01,  0.2182E-03, -0.1665E-06,  &
  0.1999E+02, -0.6889E-01,  0.1839E-03, -0.1255E-06,  &   
  0.3124E+02, -0.1223E+00,  0.2750E-03, -0.2178E-06,  &
  0.3096E+02, -0.1212E+00,  0.2735E-03, -0.2167E-06,  &
  0.3009E+02, -0.1178E+00,  0.2681E-03, -0.2123E-06,  &
  0.2861E+02, -0.1118E+00,  0.2588E-03, -0.2048E-06,  &
  0.2642E+02, -0.1020E+00,  0.2422E-03, -0.1902E-06,  &
  0.2356E+02, -0.8818E-01,  0.2182E-03, -0.1665E-06,  &
  0.1999E+02, -0.6889E-01,  0.1839E-03, -0.1255E-06   /
contains
!------------------------------------------------------------------------
	subroutine tf_table(n1,n2,ib)
	implicit none
	integer n1,n2,i,ii
	logical ib(n1,n2)
	if(  uvinit ) return
	do i=1,n2
	do ii=1,n1
	ib(ii,i)=btest(i-1,ii-1)
	enddo
!	print*,i,ib(1:n1,i)
	enddo
	uvinit = .true.
	return
	end subroutine tf_table
!-----------------------------------------------------------------------
	integer function ilui(iva)
	implicit none
	integer i,k
	integer  iva(nv)
	integer  mva(nv)

	mva(1)=nva(1)
	do i=2,nv
	 mva(i)=mva(i-1)*nva(i)
	enddo

	k= iva(1)
	do i=2,nv
	k= k+ (iva(i)-1)*mva(i-1)
	enddo

	ilui=k
	return
	end function ilui
!----------------------------------------------------------------
subroutine uva_lut
implicit none
	real A_vt,A_value,E_vt,E_value
	real swx,wx,rmin,rmax

	integer i,j,ik,k,iv,in
	integer  iva(nv,2**nv)
	
	real wb(nv),wt(nv),rva(nv),val(nv)
	integer ibase(nv),itop(nv)
	
	real o3x(3)

	o3x(1)=uvco%o3
	do i=2,3
	 o3x(i) = o3x(i-1)*o3x(1)
 	enddo

	val(1) =  acos(uvco%u0)*(180.0/3.14159)	! Cos Sol to SZA
	val(2) =  uvco%tauabs       !! ABSORPTION AOT = TAU_band6 *(1-ssa)
	val(3) =  uvco%salb		! Spectral Surface Albedo in UV
	
	 call tf_table(nv,2**nv,ichoose)
!--------------------
	 VSET : do iv=1,nv 
	rmin = anodes(1,iv)
	rmax = anodes(nva(iv),iv)

	if (val(iv) <= rmin )then 
	  rva(iv) = 1
	elseif (val(iv) >= rmax ) then
	  rva(iv) = nva(iv)
	else

	FNODES : do in = 1,nva(iv)-1
	if( val(iv) >= anodes(in,iv) .and. val(iv) < anodes(in+1,iv)) & 
     	rva(iv)= in+( val(iv)-anodes(in,iv)) /                        &
                    (anodes(in+1,iv)-anodes(in,iv))
	enddo FNODES

	endif

!	print*,iv,rva(iv)
	enddo VSET
!---------------------

	 ibase = floor(rva)
	 where( ibase < 1) ibase=1

	 itop= ceiling(rva)
	 where( itop > nva) itop=nva

	wb=1.0-(rva-ibase)
	wt=1.0-wb
	
!	print'(A10,10f5.1)','Exact',rva(1:nv)
!	print'(A10,10I5)','BASE',ibase
!	print'(A10,10I5)','TOP',itop
!	print'(A10,10f5.1)','Wb',wb	
!	print'(A10,10f5.1)','Wt',wt

	swx=0 ;  A_value =0 ;E_value =0 ; ik=0

	NODE : do j=1,2**nv
	wx=1.0

	 DIMENSION: do i=1,nv

	 if( ichoose(i,j) ) then
	  iva(i,j) = itop(i)
	  wx=wx*wt(i)
	 else
	  iva(i,j) = ibase(i)
	  wx=wx*wb(i)
	 endif

	 enddo DIMENSION

	 if( wx > 0 ) then
	 ik=ik+1
	 k = ilui(iva(1,j))

	 A_vt  = cuva(k) 
	 E_vt  = cery(0,k) + cery(1,k)*o3x(1) + cery(2,k)*o3x(2)+ cery(3,k)*o3x(3)
	 swx       = swx  +               wx

	 A_value      = A_value + A_vt * wx
	 E_value      = E_value + E_vt * wx

!	print'(2I4,i10,4f10.5,10I4)',ik,j,k, A_vt,B_vt ,wx,swx,iva(1:nv,j)
!	if (swx >= 0.9999 )exit
	endif

	enddo NODE
    
	uvco%cr_uva = 100. / (A_value/swx)	    
	uvco%uva = uvco%swdn_b6 * uvco%cr_uva
	
	uvco%cr_ery = (E_value/swx)/100.  !!! CORRECTION ERY
	uvco%ery =  uvco%uvb * uvco%cr_ery !!! YES UVB  needed here!!!
	uvco%uvi = uvco%ery *40.
	return

	end subroutine uva_lut

END MODULE UVA_CORRECTION

!#########################################################################

MODULE UVB_CORRECTION_CLOUDY
USE WSU_TYPEDEF ,only : uvco
implicit none
private
public ::  uvco,uvb_lut_cloudy

integer ,parameter :: nv = 5  ,mxn =8 
! nv = # of Variables in look up table.
! mxn = Max # of nodes for any single variable
! nva = # of nodes for each variables
! anodes = The values at each node in the table; for all variables
 
integer nva(nv)
real,save:: anodes(mxn,nv)
logical ,save:: ichoose(nv,2**nv), uvbinitcldy = .false.

data nva  /8,7,3,2,2/

! 1-8 Cloud Tau
data anodes(1:8,1) /1.000,5.000,10.000,20.000,30.000,40.000,60.000,99.000/

!!1-7 sza
data anodes(1:7,2) /  0. , 10. , 20. , 30. , 40. , 50. , 60./

!!!1-3 Cloud Height
data anodes(1:3,3) /2.000,4.500,9.000/

!!!! 1-2 Sfcalb in band 5
data anodes(1:2,4) /0.078, 0.920/

!!!!! 1-2 Percent O3 Below 20km
data anodes(1:2,5) /0.1,0.9/



 real cuvb(0:4,672) !

 !8 CLDTAU   1.000   5.000  10.000  20.000  30.000  40.000  60.000  99.000
 !7    SZA   0.000  10.000  20.000  30.000  40.000  50.000  60.000
 !3 CLDHgt   2.000   4.500   9.000
 !4 O3Pct   40.000  72.000
 !5 Sfcalb   0.078   0.920
  data cuvb  (0:4, 1 : 56 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1449E+03,  0.2718E+00, -0.1702E-03, -0.2304E-06,  0.1719E-10,  &
  0.1465E+03,  0.2687E+00, -0.1795E-03, -0.2239E-06,  0.1445E-10,  &
  0.1481E+03,  0.2642E+00, -0.1919E-03, -0.2154E-06,  0.1184E-10,  &
  0.1486E+03,  0.2612E+00, -0.1963E-03, -0.2081E-06,  0.8566E-11,  &
  0.1490E+03,  0.2573E+00, -0.2011E-03, -0.2002E-06,  0.5939E-11,  &
  0.1500E+03,  0.2493E+00, -0.1996E-03, -0.1920E-06,  0.0000E+00,  &
  0.1504E+03,  0.2445E+00, -0.2180E-03, -0.1761E-06,  0.5540E-12,  &
  0.1523E+03,  0.2269E+00, -0.2421E-03, -0.1454E-06, -0.3534E-11,  &
  0.1458E+03,  0.2714E+00, -0.1713E-03, -0.2312E-06,  0.1356E-10,  &
  0.1473E+03,  0.2683E+00, -0.1810E-03, -0.2246E-06,  0.1110E-10,  &
  0.1489E+03,  0.2637E+00, -0.1933E-03, -0.2159E-06,  0.8536E-11,  &
  0.1493E+03,  0.2599E+00, -0.1964E-03, -0.2083E-06,  0.4662E-11,  &
  0.1497E+03,  0.2567E+00, -0.2025E-03, -0.2004E-06,  0.2936E-11,  &
  0.1502E+03,  0.2525E+00, -0.2080E-03, -0.1921E-06,  0.1059E-11,  &
  0.1509E+03,  0.2458E+00, -0.2238E-03, -0.1752E-06,  0.0000E+00,  &
  0.1531E+03,  0.2254E+00, -0.2428E-03, -0.1443E-06, -0.5662E-11,  &
  0.1486E+03,  0.2702E+00, -0.1751E-03, -0.2328E-06,  0.2131E-11,  &
  0.1501E+03,  0.2664E+00, -0.1841E-03, -0.2254E-06, -0.4403E-12,  &
  0.1515E+03,  0.2611E+00, -0.1965E-03, -0.2158E-06, -0.2352E-11,  &
  0.1519E+03,  0.2578E+00, -0.2003E-03, -0.2087E-06, -0.5283E-11,  &
  0.1524E+03,  0.2538E+00, -0.2051E-03, -0.2010E-06, -0.7153E-11,  &
  0.1527E+03,  0.2501E+00, -0.2112E-03, -0.1932E-06, -0.8147E-11,  &
  0.1537E+03,  0.2409E+00, -0.2215E-03, -0.1776E-06, -0.1045E-10,  &
  0.1557E+03,  0.2227E+00, -0.2443E-03, -0.1479E-06, -0.1185E-10,  &
  0.1538E+03,  0.2661E+00, -0.1799E-03, -0.2373E-06, -0.1986E-10,  &
  0.1549E+03,  0.2618E+00, -0.1888E-03, -0.2287E-06, -0.2107E-10,  &
  0.1565E+03,  0.2549E+00, -0.2000E-03, -0.2171E-06, -0.2198E-10,  &
  0.1567E+03,  0.2524E+00, -0.2052E-03, -0.2104E-06, -0.2276E-10,  &
  0.1570E+03,  0.2485E+00, -0.2101E-03, -0.2031E-06, -0.2329E-10,  &
  0.1574E+03,  0.2440E+00, -0.2149E-03, -0.1956E-06, -0.2358E-10,  &
  0.1583E+03,  0.2349E+00, -0.2257E-03, -0.1805E-06, -0.2299E-10,  &
  0.1599E+03,  0.2169E+00, -0.2492E-03, -0.1512E-06, -0.1880E-10,  &
  0.1620E+03,  0.2573E+00, -0.1878E-03, -0.2466E-06, -0.4924E-10,  &
  0.1628E+03,  0.2522E+00, -0.1956E-03, -0.2378E-06, -0.4747E-10,  &
  0.1639E+03,  0.2447E+00, -0.2067E-03, -0.2256E-06, -0.4394E-10,  &
  0.1640E+03,  0.2418E+00, -0.2111E-03, -0.2202E-06, -0.4256E-10,  &
  0.1644E+03,  0.2374E+00, -0.2148E-03, -0.2145E-06, -0.4088E-10,  &
  0.1647E+03,  0.2331E+00, -0.2197E-03, -0.2082E-06, -0.3844E-10,  &
  0.1655E+03,  0.2242E+00, -0.2307E-03, -0.1952E-06, -0.3243E-10,  &
  0.1670E+03,  0.2056E+00, -0.2523E-03, -0.1710E-06, -0.1807E-10,  &
  0.1746E+03,  0.2362E+00, -0.1927E-03, -0.2833E-06, -0.6051E-10,  &
  0.1749E+03,  0.2307E+00, -0.1994E-03, -0.2766E-06, -0.5144E-10,  &
  0.1756E+03,  0.2225E+00, -0.2077E-03, -0.2680E-06, -0.3935E-10,  &
  0.1756E+03,  0.2191E+00, -0.2108E-03, -0.2657E-06, -0.3191E-10,  &
  0.1758E+03,  0.2152E+00, -0.2152E-03, -0.2622E-06, -0.2379E-10,  &
  0.1761E+03,  0.2109E+00, -0.2198E-03, -0.2583E-06, -0.1523E-10,  &
  0.1768E+03,  0.2015E+00, -0.2296E-03, -0.2503E-06,  0.2966E-11,  &
  0.1782E+03,  0.1814E+00, -0.2475E-03, -0.2369E-06,  0.4224E-10,  &
  0.1944E+03,  0.1830E+00, -0.1555E-03, -0.4953E-06,  0.1308E-09,  &
  0.1942E+03,  0.1784E+00, -0.1589E-03, -0.4971E-06,  0.1525E-09,  &
  0.1944E+03,  0.1725E+00, -0.1637E-03, -0.4996E-06,  0.1803E-09,  &
  0.1944E+03,  0.1687E+00, -0.1633E-03, -0.5093E-06,  0.2038E-09,  &
  0.1945E+03,  0.1638E+00, -0.1630E-03, -0.5178E-06,  0.2275E-09,  &
  0.1947E+03,  0.1592E+00, -0.1654E-03, -0.5234E-06,  0.2509E-09,  &
  0.1951E+03,  0.1501E+00, -0.1723E-03, -0.5323E-06,  0.2981E-09,  &
  0.1963E+03,  0.1293E+00, -0.1808E-03, -0.5565E-06,  0.3965E-09   /
  data cuvb  (0:4, 57 : 112 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1449E+03,  0.2724E+00, -0.1701E-03, -0.2309E-06,  0.1709E-10,  &
  0.1466E+03,  0.2694E+00, -0.1776E-03, -0.2249E-06,  0.1280E-10,  &
  0.1483E+03,  0.2648E+00, -0.1895E-03, -0.2165E-06,  0.9820E-11,  &
  0.1487E+03,  0.2610E+00, -0.1931E-03, -0.2089E-06,  0.6298E-11,  &
  0.1490E+03,  0.2571E+00, -0.1982E-03, -0.2010E-06,  0.4013E-11,  &
  0.1495E+03,  0.2525E+00, -0.2035E-03, -0.1928E-06,  0.2067E-11,  &
  0.1503E+03,  0.2440E+00, -0.2161E-03, -0.1765E-06, -0.3421E-12,  &
  0.1522E+03,  0.2256E+00, -0.2400E-03, -0.1455E-06, -0.4078E-11,  &
  0.1458E+03,  0.2721E+00, -0.1714E-03, -0.2317E-06,  0.1356E-10,  &
  0.1474E+03,  0.2690E+00, -0.1788E-03, -0.2255E-06,  0.9285E-11,  &
  0.1491E+03,  0.2638E+00, -0.1901E-03, -0.2168E-06,  0.6099E-11,  &
  0.1495E+03,  0.2599E+00, -0.1936E-03, -0.2091E-06,  0.2665E-11,  &
  0.1497E+03,  0.2565E+00, -0.2002E-03, -0.2010E-06,  0.1430E-11,  &
  0.1503E+03,  0.2516E+00, -0.2049E-03, -0.1927E-06, -0.7513E-12,  &
  0.1512E+03,  0.2422E+00, -0.2162E-03, -0.1761E-06, -0.3514E-11,  &
  0.1529E+03,  0.2243E+00, -0.2414E-03, -0.1442E-06, -0.5925E-11,  &
  0.1487E+03,  0.2702E+00, -0.1741E-03, -0.2330E-06,  0.1299E-11,  &
  0.1502E+03,  0.2664E+00, -0.1813E-03, -0.2261E-06, -0.2572E-11,  &
  0.1517E+03,  0.2609E+00, -0.1933E-03, -0.2166E-06, -0.4705E-11,  &
  0.1521E+03,  0.2570E+00, -0.1967E-03, -0.2094E-06, -0.7528E-11,  &
  0.1523E+03,  0.2534E+00, -0.2026E-03, -0.2017E-06, -0.8599E-11,  &
  0.1526E+03,  0.2493E+00, -0.2085E-03, -0.1936E-06, -0.9446E-11,  &
  0.1535E+03,  0.2396E+00, -0.2189E-03, -0.1778E-06, -0.1141E-10,  &
  0.1553E+03,  0.2212E+00, -0.2426E-03, -0.1476E-06, -0.1204E-10,  &
  0.1539E+03,  0.2661E+00, -0.1789E-03, -0.2377E-06, -0.2065E-10,  &
  0.1551E+03,  0.2618E+00, -0.1867E-03, -0.2295E-06, -0.2257E-10,  &
  0.1564E+03,  0.2553E+00, -0.1988E-03, -0.2179E-06, -0.2274E-10,  &
  0.1567E+03,  0.2514E+00, -0.2024E-03, -0.2109E-06, -0.2414E-10,  &
  0.1570E+03,  0.2474E+00, -0.2078E-03, -0.2033E-06, -0.2425E-10,  &
  0.1573E+03,  0.2430E+00, -0.2132E-03, -0.1956E-06, -0.2416E-10,  &
  0.1581E+03,  0.2335E+00, -0.2241E-03, -0.1801E-06, -0.2321E-10,  &
  0.1598E+03,  0.2143E+00, -0.2470E-03, -0.1505E-06, -0.1884E-10,  &
  0.1620E+03,  0.2571E+00, -0.1864E-03, -0.2471E-06, -0.4998E-10,  &
  0.1628E+03,  0.2518E+00, -0.1943E-03, -0.2381E-06, -0.4809E-10,  &
  0.1638E+03,  0.2441E+00, -0.2057E-03, -0.2256E-06, -0.4418E-10,  &
  0.1640E+03,  0.2400E+00, -0.2087E-03, -0.2201E-06, -0.4307E-10,  &
  0.1642E+03,  0.2357E+00, -0.2133E-03, -0.2138E-06, -0.4093E-10,  &
  0.1645E+03,  0.2315E+00, -0.2188E-03, -0.2071E-06, -0.3825E-10,  &
  0.1652E+03,  0.2215E+00, -0.2284E-03, -0.1943E-06, -0.3240E-10,  &
  0.1668E+03,  0.2023E+00, -0.2504E-03, -0.1690E-06, -0.1783E-10,  &
  0.1746E+03,  0.2358E+00, -0.1917E-03, -0.2838E-06, -0.6074E-10,  &
  0.1749E+03,  0.2294E+00, -0.1989E-03, -0.2758E-06, -0.5129E-10,  &
  0.1754E+03,  0.2212E+00, -0.2081E-03, -0.2659E-06, -0.3898E-10,  &
  0.1754E+03,  0.2172E+00, -0.2112E-03, -0.2629E-06, -0.3153E-10,  &
  0.1757E+03,  0.2124E+00, -0.2146E-03, -0.2593E-06, -0.2351E-10,  &
  0.1759E+03,  0.2077E+00, -0.2188E-03, -0.2553E-06, -0.1505E-10,  &
  0.1765E+03,  0.1978E+00, -0.2288E-03, -0.2462E-06,  0.2918E-11,  &
  0.1779E+03,  0.1774E+00, -0.2476E-03, -0.2304E-06,  0.4124E-10,  &
  0.1944E+03,  0.1823E+00, -0.1557E-03, -0.4937E-06,  0.1305E-09,  &
  0.1940E+03,  0.1770E+00, -0.1622E-03, -0.4892E-06,  0.1505E-09,  &
  0.1943E+03,  0.1696E+00, -0.1648E-03, -0.4922E-06,  0.1780E-09,  &
  0.1941E+03,  0.1657E+00, -0.1661E-03, -0.4988E-06,  0.2003E-09,  &
  0.1942E+03,  0.1612E+00, -0.1682E-03, -0.5039E-06,  0.2228E-09,  &
  0.1944E+03,  0.1559E+00, -0.1693E-03, -0.5096E-06,  0.2457E-09,  &
  0.1948E+03,  0.1459E+00, -0.1749E-03, -0.5178E-06,  0.2918E-09,  &
  0.1958E+03,  0.1251E+00, -0.1867E-03, -0.5346E-06,  0.3854E-09   /
  data cuvb  (0:4, 113 : 168 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1450E+03,  0.2736E+00, -0.1694E-03, -0.2320E-06,  0.1633E-10,  &
  0.1471E+03,  0.2721E+00, -0.1730E-03, -0.2279E-06,  0.8592E-11,  &
  0.1490E+03,  0.2678E+00, -0.1829E-03, -0.2205E-06,  0.4124E-11,  &
  0.1493E+03,  0.2648E+00, -0.1872E-03, -0.2136E-06,  0.1096E-11,  &
  0.1497E+03,  0.2611E+00, -0.1928E-03, -0.2059E-06, -0.7193E-12,  &
  0.1501E+03,  0.2564E+00, -0.1981E-03, -0.1979E-06, -0.2520E-11,  &
  0.1510E+03,  0.2472E+00, -0.2107E-03, -0.1816E-06, -0.4551E-11,  &
  0.1528E+03,  0.2291E+00, -0.2373E-03, -0.1502E-06, -0.6362E-11,  &
  0.1460E+03,  0.2726E+00, -0.1695E-03, -0.2323E-06,  0.1186E-10,  &
  0.1479E+03,  0.2714E+00, -0.1742E-03, -0.2285E-06,  0.5098E-11,  &
  0.1497E+03,  0.2668E+00, -0.1841E-03, -0.2209E-06,  0.7865E-12,  &
  0.1501E+03,  0.2640E+00, -0.1887E-03, -0.2140E-06, -0.1910E-11,  &
  0.1505E+03,  0.2596E+00, -0.1934E-03, -0.2059E-06, -0.4121E-11,  &
  0.1508E+03,  0.2555E+00, -0.1999E-03, -0.1977E-06, -0.5050E-11,  &
  0.1517E+03,  0.2460E+00, -0.2120E-03, -0.1811E-06, -0.7028E-11,  &
  0.1534E+03,  0.2269E+00, -0.2373E-03, -0.1491E-06, -0.8547E-11,  &
  0.1489E+03,  0.2707E+00, -0.1722E-03, -0.2338E-06, -0.4593E-12,  &
  0.1506E+03,  0.2692E+00, -0.1780E-03, -0.2294E-06, -0.5856E-11,  &
  0.1521E+03,  0.2644E+00, -0.1890E-03, -0.2209E-06, -0.8657E-11,  &
  0.1525E+03,  0.2608E+00, -0.1922E-03, -0.2141E-06, -0.1161E-10,  &
  0.1529E+03,  0.2565E+00, -0.1970E-03, -0.2066E-06, -0.1316E-10,  &
  0.1533E+03,  0.2522E+00, -0.2030E-03, -0.1986E-06, -0.1377E-10,  &
  0.1541E+03,  0.2431E+00, -0.2154E-03, -0.1827E-06, -0.1443E-10,  &
  0.1558E+03,  0.2243E+00, -0.2409E-03, -0.1516E-06, -0.1364E-10,  &
  0.1540E+03,  0.2669E+00, -0.1775E-03, -0.2388E-06, -0.2188E-10,  &
  0.1554E+03,  0.2638E+00, -0.1831E-03, -0.2326E-06, -0.2573E-10,  &
  0.1569E+03,  0.2577E+00, -0.1946E-03, -0.2219E-06, -0.2629E-10,  &
  0.1570E+03,  0.2547E+00, -0.1990E-03, -0.2154E-06, -0.2719E-10,  &
  0.1573E+03,  0.2502E+00, -0.2036E-03, -0.2079E-06, -0.2753E-10,  &
  0.1576E+03,  0.2460E+00, -0.2098E-03, -0.2001E-06, -0.2691E-10,  &
  0.1584E+03,  0.2364E+00, -0.2216E-03, -0.1843E-06, -0.2525E-10,  &
  0.1600E+03,  0.2168E+00, -0.2461E-03, -0.1536E-06, -0.1975E-10,  &
  0.1621E+03,  0.2581E+00, -0.1858E-03, -0.2483E-06, -0.5074E-10,  &
  0.1629E+03,  0.2537E+00, -0.1931E-03, -0.2406E-06, -0.4940E-10,  &
  0.1639E+03,  0.2461E+00, -0.2041E-03, -0.2284E-06, -0.4559E-10,  &
  0.1641E+03,  0.2424E+00, -0.2074E-03, -0.2232E-06, -0.4443E-10,  &
  0.1644E+03,  0.2380E+00, -0.2116E-03, -0.2172E-06, -0.4234E-10,  &
  0.1647E+03,  0.2333E+00, -0.2168E-03, -0.2105E-06, -0.3957E-10,  &
  0.1654E+03,  0.2239E+00, -0.2287E-03, -0.1964E-06, -0.3292E-10,  &
  0.1668E+03,  0.2040E+00, -0.2516E-03, -0.1697E-06, -0.1790E-10,  &
  0.1746E+03,  0.2362E+00, -0.1914E-03, -0.2844E-06, -0.6092E-10,  &
  0.1747E+03,  0.2296E+00, -0.1996E-03, -0.2752E-06, -0.5110E-10,  &
  0.1754E+03,  0.2216E+00, -0.2096E-03, -0.2648E-06, -0.3875E-10,  &
  0.1754E+03,  0.2178E+00, -0.2125E-03, -0.2623E-06, -0.3142E-10,  &
  0.1757E+03,  0.2131E+00, -0.2161E-03, -0.2587E-06, -0.2343E-10,  &
  0.1759E+03,  0.2089E+00, -0.2219E-03, -0.2534E-06, -0.1492E-10,  &
  0.1764E+03,  0.1989E+00, -0.2325E-03, -0.2432E-06,  0.2884E-11,  &
  0.1778E+03,  0.1779E+00, -0.2530E-03, -0.2241E-06,  0.4039E-10,  &
  0.1943E+03,  0.1818E+00, -0.1581E-03, -0.4893E-06,  0.1295E-09,  &
  0.1937E+03,  0.1757E+00, -0.1704E-03, -0.4745E-06,  0.1470E-09,  &
  0.1939E+03,  0.1689E+00, -0.1747E-03, -0.4753E-06,  0.1734E-09,  &
  0.1939E+03,  0.1648E+00, -0.1748E-03, -0.4832E-06,  0.1957E-09,  &
  0.1939E+03,  0.1606E+00, -0.1777E-03, -0.4871E-06,  0.2175E-09,  &
  0.1941E+03,  0.1551E+00, -0.1784E-03, -0.4927E-06,  0.2400E-09,  &
  0.1945E+03,  0.1450E+00, -0.1856E-03, -0.4978E-06,  0.2842E-09,  &
  0.1954E+03,  0.1243E+00, -0.2007E-03, -0.5066E-06,  0.3729E-09   /
  data cuvb  (0:4, 169 : 224 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1448E+03,  0.2694E+00, -0.1802E-03, -0.2273E-06,  0.2559E-10,  &
  0.1462E+03,  0.2653E+00, -0.1909E-03, -0.2193E-06,  0.2386E-10,  &
  0.1478E+03,  0.2601E+00, -0.2051E-03, -0.2091E-06,  0.2245E-10,  &
  0.1480E+03,  0.2565E+00, -0.2124E-03, -0.2000E-06,  0.2107E-10,  &
  0.1483E+03,  0.2522E+00, -0.2192E-03, -0.1905E-06,  0.1949E-10,  &
  0.1487E+03,  0.2473E+00, -0.2258E-03, -0.1807E-06,  0.1782E-10,  &
  0.1494E+03,  0.2377E+00, -0.2399E-03, -0.1611E-06,  0.1518E-10,  &
  0.1510E+03,  0.2183E+00, -0.2677E-03, -0.1230E-06,  0.1061E-10,  &
  0.1457E+03,  0.2688E+00, -0.1813E-03, -0.2277E-06,  0.2193E-10,  &
  0.1471E+03,  0.2647E+00, -0.1922E-03, -0.2196E-06,  0.2038E-10,  &
  0.1487E+03,  0.2594E+00, -0.2065E-03, -0.2092E-06,  0.1908E-10,  &
  0.1488E+03,  0.2558E+00, -0.2137E-03, -0.1999E-06,  0.1781E-10,  &
  0.1491E+03,  0.2514E+00, -0.2209E-03, -0.1901E-06,  0.1658E-10,  &
  0.1495E+03,  0.2460E+00, -0.2264E-03, -0.1801E-06,  0.1440E-10,  &
  0.1502E+03,  0.2368E+00, -0.2418E-03, -0.1600E-06,  0.1258E-10,  &
  0.1518E+03,  0.2168E+00, -0.2690E-03, -0.1209E-06,  0.8289E-11,  &
  0.1486E+03,  0.2672E+00, -0.1856E-03, -0.2284E-06,  0.1073E-10,  &
  0.1498E+03,  0.2627E+00, -0.1964E-03, -0.2194E-06,  0.9504E-11,  &
  0.1513E+03,  0.2569E+00, -0.2107E-03, -0.2080E-06,  0.8582E-11,  &
  0.1515E+03,  0.2530E+00, -0.2174E-03, -0.1988E-06,  0.7449E-11,  &
  0.1519E+03,  0.2481E+00, -0.2235E-03, -0.1892E-06,  0.6091E-11,  &
  0.1522E+03,  0.2436E+00, -0.2306E-03, -0.1795E-06,  0.5339E-11,  &
  0.1529E+03,  0.2340E+00, -0.2450E-03, -0.1598E-06,  0.4106E-11,  &
  0.1543E+03,  0.2143E+00, -0.2722E-03, -0.1217E-06,  0.1798E-11,  &
  0.1538E+03,  0.2635E+00, -0.1927E-03, -0.2313E-06, -0.9877E-11,  &
  0.1549E+03,  0.2579E+00, -0.2027E-03, -0.2206E-06, -0.1058E-10,  &
  0.1563E+03,  0.2512E+00, -0.2170E-03, -0.2068E-06, -0.1018E-10,  &
  0.1564E+03,  0.2472E+00, -0.2239E-03, -0.1975E-06, -0.1018E-10,  &
  0.1567E+03,  0.2429E+00, -0.2312E-03, -0.1878E-06, -0.9904E-11,  &
  0.1570E+03,  0.2378E+00, -0.2376E-03, -0.1779E-06, -0.9908E-11,  &
  0.1576E+03,  0.2279E+00, -0.2514E-03, -0.1581E-06, -0.9316E-11,  &
  0.1591E+03,  0.2071E+00, -0.2776E-03, -0.1198E-06, -0.7635E-11,  &
  0.1621E+03,  0.2542E+00, -0.2025E-03, -0.2365E-06, -0.3937E-10,  &
  0.1629E+03,  0.2487E+00, -0.2136E-03, -0.2248E-06, -0.3648E-10,  &
  0.1639E+03,  0.2411E+00, -0.2275E-03, -0.2095E-06, -0.3271E-10,  &
  0.1640E+03,  0.2368E+00, -0.2336E-03, -0.2009E-06, -0.3095E-10,  &
  0.1642E+03,  0.2322E+00, -0.2402E-03, -0.1918E-06, -0.2886E-10,  &
  0.1645E+03,  0.2268E+00, -0.2459E-03, -0.1828E-06, -0.2686E-10,  &
  0.1650E+03,  0.2173E+00, -0.2609E-03, -0.1636E-06, -0.2171E-10,  &
  0.1664E+03,  0.1963E+00, -0.2868E-03, -0.1274E-06, -0.1156E-10,  &
  0.1749E+03,  0.2341E+00, -0.2160E-03, -0.2617E-06, -0.5259E-10,  &
  0.1752E+03,  0.2279E+00, -0.2252E-03, -0.2510E-06, -0.4405E-10,  &
  0.1757E+03,  0.2204E+00, -0.2382E-03, -0.2366E-06, -0.3298E-10,  &
  0.1758E+03,  0.2159E+00, -0.2441E-03, -0.2292E-06, -0.2630E-10,  &
  0.1759E+03,  0.2113E+00, -0.2512E-03, -0.2207E-06, -0.1931E-10,  &
  0.1762E+03,  0.2057E+00, -0.2564E-03, -0.2133E-06, -0.1228E-10,  &
  0.1767E+03,  0.1952E+00, -0.2697E-03, -0.1965E-06,  0.2341E-11,  &
  0.1778E+03,  0.1739E+00, -0.2955E-03, -0.1640E-06,  0.3206E-10,  &
  0.1945E+03,  0.1850E+00, -0.2063E-03, -0.4265E-06,  0.1167E-09,  &
  0.1942E+03,  0.1811E+00, -0.2160E-03, -0.4186E-06,  0.1345E-09,  &
  0.1944E+03,  0.1751E+00, -0.2247E-03, -0.4129E-06,  0.1577E-09,  &
  0.1944E+03,  0.1711E+00, -0.2308E-03, -0.4105E-06,  0.1758E-09,  &
  0.1943E+03,  0.1665E+00, -0.2365E-03, -0.4078E-06,  0.1941E-09,  &
  0.1945E+03,  0.1614E+00, -0.2421E-03, -0.4049E-06,  0.2125E-09,  &
  0.1948E+03,  0.1511E+00, -0.2543E-03, -0.3976E-06,  0.2491E-09,  &
  0.1956E+03,  0.1295E+00, -0.2762E-03, -0.3857E-06,  0.3228E-09   /
  data cuvb  (0:4, 225 : 280 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1447E+03,  0.2699E+00, -0.1806E-03, -0.2277E-06,  0.2597E-10,  &
  0.1462E+03,  0.2659E+00, -0.1904E-03, -0.2199E-06,  0.2341E-10,  &
  0.1479E+03,  0.2608E+00, -0.2043E-03, -0.2098E-06,  0.2166E-10,  &
  0.1481E+03,  0.2565E+00, -0.2102E-03, -0.2006E-06,  0.1948E-10,  &
  0.1485E+03,  0.2520E+00, -0.2169E-03, -0.1911E-06,  0.1789E-10,  &
  0.1487E+03,  0.2476E+00, -0.2243E-03, -0.1815E-06,  0.1675E-10,  &
  0.1495E+03,  0.2379E+00, -0.2383E-03, -0.1621E-06,  0.1414E-10,  &
  0.1510E+03,  0.2186E+00, -0.2658E-03, -0.1243E-06,  0.9686E-11,  &
  0.1457E+03,  0.2691E+00, -0.1814E-03, -0.2280E-06,  0.2193E-10,  &
  0.1471E+03,  0.2653E+00, -0.1917E-03, -0.2202E-06,  0.1993E-10,  &
  0.1487E+03,  0.2596E+00, -0.2049E-03, -0.2098E-06,  0.1785E-10,  &
  0.1489E+03,  0.2560E+00, -0.2123E-03, -0.2005E-06,  0.1673E-10,  &
  0.1493E+03,  0.2511E+00, -0.2183E-03, -0.1907E-06,  0.1483E-10,  &
  0.1495E+03,  0.2466E+00, -0.2256E-03, -0.1809E-06,  0.1373E-10,  &
  0.1503E+03,  0.2364E+00, -0.2389E-03, -0.1611E-06,  0.1103E-10,  &
  0.1519E+03,  0.2169E+00, -0.2670E-03, -0.1223E-06,  0.7345E-11,  &
  0.1486E+03,  0.2672E+00, -0.1850E-03, -0.2285E-06,  0.1027E-10,  &
  0.1499E+03,  0.2629E+00, -0.1955E-03, -0.2199E-06,  0.8700E-11,  &
  0.1514E+03,  0.2569E+00, -0.2091E-03, -0.2085E-06,  0.7403E-11,  &
  0.1516E+03,  0.2529E+00, -0.2158E-03, -0.1994E-06,  0.6331E-11,  &
  0.1519E+03,  0.2485E+00, -0.2225E-03, -0.1899E-06,  0.5330E-11,  &
  0.1522E+03,  0.2436E+00, -0.2289E-03, -0.1803E-06,  0.4329E-11,  &
  0.1529E+03,  0.2339E+00, -0.2429E-03, -0.1608E-06,  0.3016E-11,  &
  0.1543E+03,  0.2145E+00, -0.2707E-03, -0.1229E-06,  0.1118E-11,  &
  0.1539E+03,  0.2635E+00, -0.1922E-03, -0.2315E-06, -0.1032E-10,  &
  0.1549E+03,  0.2587E+00, -0.2029E-03, -0.2211E-06, -0.1058E-10,  &
  0.1563E+03,  0.2516E+00, -0.2167E-03, -0.2073E-06, -0.1049E-10,  &
  0.1564E+03,  0.2473E+00, -0.2228E-03, -0.1981E-06, -0.1083E-10,  &
  0.1568E+03,  0.2422E+00, -0.2285E-03, -0.1886E-06, -0.1120E-10,  &
  0.1570E+03,  0.2377E+00, -0.2359E-03, -0.1787E-06, -0.1074E-10,  &
  0.1576E+03,  0.2276E+00, -0.2496E-03, -0.1591E-06, -0.1009E-10,  &
  0.1591E+03,  0.2070E+00, -0.2757E-03, -0.1212E-06, -0.8204E-11,  &
  0.1621E+03,  0.2547E+00, -0.2033E-03, -0.2366E-06, -0.3907E-10,  &
  0.1629E+03,  0.2487E+00, -0.2130E-03, -0.2251E-06, -0.3683E-10,  &
  0.1639E+03,  0.2406E+00, -0.2260E-03, -0.2100E-06, -0.3326E-10,  &
  0.1640E+03,  0.2364E+00, -0.2322E-03, -0.2014E-06, -0.3146E-10,  &
  0.1642E+03,  0.2321E+00, -0.2397E-03, -0.1921E-06, -0.2907E-10,  &
  0.1644E+03,  0.2272E+00, -0.2463E-03, -0.1829E-06, -0.2681E-10,  &
  0.1650E+03,  0.2168E+00, -0.2593E-03, -0.1645E-06, -0.2209E-10,  &
  0.1663E+03,  0.1962E+00, -0.2853E-03, -0.1286E-06, -0.1175E-10,  &
  0.1749E+03,  0.2341E+00, -0.2160E-03, -0.2617E-06, -0.5259E-10,  &
  0.1751E+03,  0.2282E+00, -0.2261E-03, -0.2503E-06, -0.4383E-10,  &
  0.1757E+03,  0.2195E+00, -0.2367E-03, -0.2370E-06, -0.3310E-10,  &
  0.1756E+03,  0.2153E+00, -0.2433E-03, -0.2292E-06, -0.2632E-10,  &
  0.1758E+03,  0.2107E+00, -0.2505E-03, -0.2207E-06, -0.1931E-10,  &
  0.1761E+03,  0.2055E+00, -0.2566E-03, -0.2127E-06, -0.1224E-10,  &
  0.1765E+03,  0.1951E+00, -0.2703E-03, -0.1956E-06,  0.2330E-11,  &
  0.1778E+03,  0.1729E+00, -0.2936E-03, -0.1651E-06,  0.3218E-10,  &
  0.1944E+03,  0.1855E+00, -0.2084E-03, -0.4243E-06,  0.1163E-09,  &
  0.1941E+03,  0.1805E+00, -0.2163E-03, -0.4169E-06,  0.1340E-09,  &
  0.1944E+03,  0.1743E+00, -0.2254E-03, -0.4103E-06,  0.1569E-09,  &
  0.1942E+03,  0.1703E+00, -0.2312E-03, -0.4081E-06,  0.1750E-09,  &
  0.1942E+03,  0.1659E+00, -0.2373E-03, -0.4049E-06,  0.1931E-09,  &
  0.1944E+03,  0.1604E+00, -0.2423E-03, -0.4023E-06,  0.2114E-09,  &
  0.1946E+03,  0.1502E+00, -0.2545E-03, -0.3950E-06,  0.2479E-09,  &
  0.1955E+03,  0.1283E+00, -0.2753E-03, -0.3843E-06,  0.3217E-09   /
  data cuvb  (0:4, 281 : 336 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1449E+03,  0.2701E+00, -0.1781E-03, -0.2282E-06,  0.2379E-10,  &
  0.1469E+03,  0.2679E+00, -0.1842E-03, -0.2227E-06,  0.1792E-10,  &
  0.1488E+03,  0.2636E+00, -0.1951E-03, -0.2145E-06,  0.1386E-10,  &
  0.1493E+03,  0.2608E+00, -0.1991E-03, -0.2073E-06,  0.1024E-10,  &
  0.1498E+03,  0.2574E+00, -0.2046E-03, -0.1996E-06,  0.7861E-11,  &
  0.1503E+03,  0.2529E+00, -0.2093E-03, -0.1914E-06,  0.5279E-11,  &
  0.1514E+03,  0.2443E+00, -0.2209E-03, -0.1753E-06,  0.1865E-11,  &
  0.1534E+03,  0.2264E+00, -0.2442E-03, -0.1446E-06, -0.2827E-11,  &
  0.1459E+03,  0.2696E+00, -0.1795E-03, -0.2287E-06,  0.2024E-10,  &
  0.1478E+03,  0.2673E+00, -0.1855E-03, -0.2231E-06,  0.1438E-10,  &
  0.1495E+03,  0.2632E+00, -0.1970E-03, -0.2149E-06,  0.1098E-10,  &
  0.1501E+03,  0.2601E+00, -0.2010E-03, -0.2075E-06,  0.7408E-11,  &
  0.1506E+03,  0.2559E+00, -0.2051E-03, -0.1994E-06,  0.4365E-11,  &
  0.1511E+03,  0.2517E+00, -0.2107E-03, -0.1911E-06,  0.2416E-11,  &
  0.1521E+03,  0.2431E+00, -0.2223E-03, -0.1745E-06, -0.6738E-12,  &
  0.1541E+03,  0.2253E+00, -0.2464E-03, -0.1429E-06, -0.4456E-11,  &
  0.1488E+03,  0.2678E+00, -0.1831E-03, -0.2294E-06,  0.8602E-11,  &
  0.1505E+03,  0.2652E+00, -0.1897E-03, -0.2233E-06,  0.3642E-11,  &
  0.1522E+03,  0.2598E+00, -0.2005E-03, -0.2139E-06,  0.2558E-12,  &
  0.1526E+03,  0.2573E+00, -0.2052E-03, -0.2069E-06, -0.2239E-11,  &
  0.1531E+03,  0.2535E+00, -0.2099E-03, -0.1992E-06, -0.4335E-11,  &
  0.1536E+03,  0.2487E+00, -0.2140E-03, -0.1914E-06, -0.6487E-11,  &
  0.1545E+03,  0.2402E+00, -0.2257E-03, -0.1755E-06, -0.8400E-11,  &
  0.1564E+03,  0.2227E+00, -0.2496E-03, -0.1451E-06, -0.1000E-10,  &
  0.1540E+03,  0.2642E+00, -0.1902E-03, -0.2328E-06, -0.1200E-10,  &
  0.1554E+03,  0.2606E+00, -0.1966E-03, -0.2252E-06, -0.1566E-10,  &
  0.1569E+03,  0.2547E+00, -0.2087E-03, -0.2134E-06, -0.1657E-10,  &
  0.1573E+03,  0.2511E+00, -0.2119E-03, -0.2067E-06, -0.1876E-10,  &
  0.1578E+03,  0.2470E+00, -0.2163E-03, -0.1993E-06, -0.1981E-10,  &
  0.1581E+03,  0.2433E+00, -0.2225E-03, -0.1914E-06, -0.1975E-10,  &
  0.1591E+03,  0.2341E+00, -0.2330E-03, -0.1758E-06, -0.1979E-10,  &
  0.1609E+03,  0.2155E+00, -0.2552E-03, -0.1462E-06, -0.1690E-10,  &
  0.1623E+03,  0.2552E+00, -0.2008E-03, -0.2384E-06, -0.4080E-10,  &
  0.1633E+03,  0.2505E+00, -0.2078E-03, -0.2299E-06, -0.4042E-10,  &
  0.1644E+03,  0.2433E+00, -0.2192E-03, -0.2170E-06, -0.3762E-10,  &
  0.1646E+03,  0.2400E+00, -0.2228E-03, -0.2114E-06, -0.3701E-10,  &
  0.1650E+03,  0.2360E+00, -0.2270E-03, -0.2051E-06, -0.3565E-10,  &
  0.1653E+03,  0.2319E+00, -0.2322E-03, -0.1984E-06, -0.3363E-10,  &
  0.1661E+03,  0.2228E+00, -0.2428E-03, -0.1848E-06, -0.2872E-10,  &
  0.1678E+03,  0.2038E+00, -0.2633E-03, -0.1595E-06, -0.1631E-10,  &
  0.1750E+03,  0.2345E+00, -0.2133E-03, -0.2645E-06, -0.5359E-10,  &
  0.1753E+03,  0.2282E+00, -0.2196E-03, -0.2564E-06, -0.4563E-10,  &
  0.1759E+03,  0.2210E+00, -0.2311E-03, -0.2444E-06, -0.3455E-10,  &
  0.1761E+03,  0.2177E+00, -0.2345E-03, -0.2412E-06, -0.2812E-10,  &
  0.1763E+03,  0.2138E+00, -0.2389E-03, -0.2368E-06, -0.2103E-10,  &
  0.1767E+03,  0.2091E+00, -0.2427E-03, -0.2327E-06, -0.1354E-10,  &
  0.1774E+03,  0.1997E+00, -0.2523E-03, -0.2230E-06,  0.2650E-11,  &
  0.1788E+03,  0.1805E+00, -0.2725E-03, -0.2046E-06,  0.3781E-10,  &
  0.1945E+03,  0.1850E+00, -0.2057E-03, -0.4274E-06,  0.1169E-09,  &
  0.1941E+03,  0.1800E+00, -0.2149E-03, -0.4182E-06,  0.1342E-09,  &
  0.1943E+03,  0.1746E+00, -0.2225E-03, -0.4149E-06,  0.1581E-09,  &
  0.1944E+03,  0.1704E+00, -0.2221E-03, -0.4226E-06,  0.1792E-09,  &
  0.1945E+03,  0.1664E+00, -0.2245E-03, -0.4268E-06,  0.2000E-09,  &
  0.1947E+03,  0.1616E+00, -0.2260E-03, -0.4315E-06,  0.2213E-09,  &
  0.1951E+03,  0.1530E+00, -0.2348E-03, -0.4350E-06,  0.2633E-09,  &
  0.1964E+03,  0.1326E+00, -0.2456E-03, -0.4497E-06,  0.3517E-09   /
  data cuvb  (0:4, 337 : 392 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1438E+03,  0.2626E+00, -0.1877E-03, -0.2039E-06,  0.1576E-10,  &
  0.1461E+03,  0.2555E+00, -0.2029E-03, -0.1915E-06,  0.1256E-10,  &
  0.1486E+03,  0.2459E+00, -0.2210E-03, -0.1764E-06,  0.8627E-11,  &
  0.1498E+03,  0.2398E+00, -0.2279E-03, -0.1609E-06,  0.4471E-11,  &
  0.1510E+03,  0.2332E+00, -0.2357E-03, -0.1451E-06,  0.1525E-11,  &
  0.1520E+03,  0.2263E+00, -0.2442E-03, -0.1291E-06, -0.4880E-12,  &
  0.1541E+03,  0.2114E+00, -0.2621E-03, -0.9702E-07, -0.2591E-11,  &
  0.1574E+03,  0.1805E+00, -0.3011E-03, -0.3407E-07, -0.8866E-12,  &
  0.1448E+03,  0.2623E+00, -0.1892E-03, -0.2047E-06,  0.1265E-10,  &
  0.1470E+03,  0.2547E+00, -0.2040E-03, -0.1914E-06,  0.9283E-11,  &
  0.1496E+03,  0.2452E+00, -0.2227E-03, -0.1754E-06,  0.5875E-11,  &
  0.1508E+03,  0.2389E+00, -0.2289E-03, -0.1602E-06,  0.1750E-11,  &
  0.1519E+03,  0.2323E+00, -0.2368E-03, -0.1445E-06, -0.7670E-12,  &
  0.1531E+03,  0.2250E+00, -0.2445E-03, -0.1289E-06, -0.2700E-11,  &
  0.1549E+03,  0.2104E+00, -0.2630E-03, -0.9683E-07, -0.3823E-11,  &
  0.1582E+03,  0.1799E+00, -0.3029E-03, -0.3374E-07, -0.6622E-12,  &
  0.1474E+03,  0.2608E+00, -0.1935E-03, -0.2062E-06,  0.2566E-11,  &
  0.1496E+03,  0.2525E+00, -0.2077E-03, -0.1923E-06, -0.3666E-12,  &
  0.1520E+03,  0.2425E+00, -0.2272E-03, -0.1752E-06, -0.2514E-11,  &
  0.1532E+03,  0.2358E+00, -0.2328E-03, -0.1604E-06, -0.5779E-11,  &
  0.1542E+03,  0.2293E+00, -0.2408E-03, -0.1449E-06, -0.7130E-11,  &
  0.1553E+03,  0.2222E+00, -0.2494E-03, -0.1291E-06, -0.7651E-11,  &
  0.1571E+03,  0.2070E+00, -0.2671E-03, -0.9752E-07, -0.6718E-11,  &
  0.1603E+03,  0.1762E+00, -0.3075E-03, -0.3424E-07,  0.1178E-11,  &
  0.1524E+03,  0.2566E+00, -0.2004E-03, -0.2097E-06, -0.1570E-10,  &
  0.1544E+03,  0.2474E+00, -0.2144E-03, -0.1935E-06, -0.1655E-10,  &
  0.1567E+03,  0.2361E+00, -0.2335E-03, -0.1736E-06, -0.1618E-10,  &
  0.1579E+03,  0.2298E+00, -0.2399E-03, -0.1599E-06, -0.1663E-10,  &
  0.1589E+03,  0.2229E+00, -0.2468E-03, -0.1459E-06, -0.1592E-10,  &
  0.1599E+03,  0.2154E+00, -0.2542E-03, -0.1318E-06, -0.1421E-10,  &
  0.1615E+03,  0.2007E+00, -0.2728E-03, -0.1018E-06, -0.8134E-11,  &
  0.1643E+03,  0.1695E+00, -0.3123E-03, -0.4249E-07,  0.9486E-11,  &
  0.1605E+03,  0.2477E+00, -0.2112E-03, -0.2157E-06, -0.3803E-10,  &
  0.1621E+03,  0.2375E+00, -0.2244E-03, -0.2001E-06, -0.3407E-10,  &
  0.1640E+03,  0.2252E+00, -0.2430E-03, -0.1802E-06, -0.2747E-10,  &
  0.1650E+03,  0.2186E+00, -0.2489E-03, -0.1685E-06, -0.2304E-10,  &
  0.1659E+03,  0.2118E+00, -0.2565E-03, -0.1558E-06, -0.1717E-10,  &
  0.1668E+03,  0.2039E+00, -0.2629E-03, -0.1437E-06, -0.1042E-10,  &
  0.1683E+03,  0.1885E+00, -0.2809E-03, -0.1165E-06,  0.5815E-11,  &
  0.1709E+03,  0.1560E+00, -0.3189E-03, -0.6262E-07,  0.4414E-10,  &
  0.1726E+03,  0.2273E+00, -0.2235E-03, -0.2490E-06, -0.3453E-10,  &
  0.1737E+03,  0.2168E+00, -0.2354E-03, -0.2359E-06, -0.1929E-10,  &
  0.1752E+03,  0.2035E+00, -0.2513E-03, -0.2195E-06,  0.1084E-11,  &
  0.1760E+03,  0.1972E+00, -0.2569E-03, -0.2134E-06,  0.1608E-10,  &
  0.1768E+03,  0.1905E+00, -0.2636E-03, -0.2062E-06,  0.3229E-10,  &
  0.1775E+03,  0.1826E+00, -0.2691E-03, -0.1998E-06,  0.4970E-10,  &
  0.1788E+03,  0.1667E+00, -0.2845E-03, -0.1834E-06,  0.8677E-10,  &
  0.1807E+03,  0.1349E+00, -0.3218E-03, -0.1457E-06,  0.1653E-09,  &
  0.1914E+03,  0.1791E+00, -0.2087E-03, -0.4433E-06,  0.1836E-09,  &
  0.1919E+03,  0.1689E+00, -0.2167E-03, -0.4421E-06,  0.2211E-09,  &
  0.1928E+03,  0.1570E+00, -0.2283E-03, -0.4412E-06,  0.2695E-09,  &
  0.1935E+03,  0.1496E+00, -0.2274E-03, -0.4549E-06,  0.3113E-09,  &
  0.1940E+03,  0.1423E+00, -0.2294E-03, -0.4647E-06,  0.3531E-09,  &
  0.1946E+03,  0.1341E+00, -0.2314E-03, -0.4741E-06,  0.3959E-09,  &
  0.1952E+03,  0.1189E+00, -0.2422E-03, -0.4849E-06,  0.4813E-09,  &
  0.1965E+03,  0.8514E-01, -0.2646E-03, -0.5034E-06,  0.6550E-09   /
  data cuvb  (0:4, 393 : 448 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1439E+03,  0.2633E+00, -0.1869E-03, -0.2047E-06,  0.1502E-10,  &
  0.1465E+03,  0.2578E+00, -0.1991E-03, -0.1945E-06,  0.9383E-11,  &
  0.1492E+03,  0.2502E+00, -0.2164E-03, -0.1817E-06,  0.4564E-11,  &
  0.1507E+03,  0.2479E+00, -0.2238E-03, -0.1692E-06,  0.0000E+00,  &
  0.1523E+03,  0.2412E+00, -0.2269E-03, -0.1564E-06, -0.5018E-11,  &
  0.1534E+03,  0.2362E+00, -0.2359E-03, -0.1423E-06, -0.6657E-11,  &
  0.1556E+03,  0.2241E+00, -0.2556E-03, -0.1129E-06, -0.7332E-11,  &
  0.1589E+03,  0.1974E+00, -0.3010E-03, -0.5180E-07, -0.1630E-11,  &
  0.1449E+03,  0.2629E+00, -0.1883E-03, -0.2054E-06,  0.1183E-10,  &
  0.1474E+03,  0.2566E+00, -0.1993E-03, -0.1945E-06,  0.5678E-11,  &
  0.1502E+03,  0.2496E+00, -0.2182E-03, -0.1809E-06,  0.1889E-11,  &
  0.1519E+03,  0.2451E+00, -0.2214E-03, -0.1690E-06, -0.4116E-11,  &
  0.1531E+03,  0.2407E+00, -0.2287E-03, -0.1559E-06, -0.6971E-11,  &
  0.1543E+03,  0.2355E+00, -0.2371E-03, -0.1421E-06, -0.8435E-11,  &
  0.1564E+03,  0.2237E+00, -0.2575E-03, -0.1126E-06, -0.8195E-11,  &
  0.1597E+03,  0.1967E+00, -0.3023E-03, -0.5213E-07, -0.1133E-11,  &
  0.1475E+03,  0.2616E+00, -0.1927E-03, -0.2070E-06,  0.1846E-11,  &
  0.1500E+03,  0.2547E+00, -0.2039E-03, -0.1956E-06, -0.3473E-11,  &
  0.1525E+03,  0.2464E+00, -0.2216E-03, -0.1812E-06, -0.6820E-11,  &
  0.1541E+03,  0.2423E+00, -0.2255E-03, -0.1699E-06, -0.1127E-10,  &
  0.1554E+03,  0.2377E+00, -0.2328E-03, -0.1571E-06, -0.1300E-10,  &
  0.1566E+03,  0.2321E+00, -0.2407E-03, -0.1437E-06, -0.1338E-10,  &
  0.1586E+03,  0.2199E+00, -0.2603E-03, -0.1150E-06, -0.1076E-10,  &
  0.1618E+03,  0.1924E+00, -0.3053E-03, -0.5512E-07,  0.1753E-11,  &
  0.1524E+03,  0.2574E+00, -0.1995E-03, -0.2107E-06, -0.1645E-10,  &
  0.1547E+03,  0.2502E+00, -0.2116E-03, -0.1974E-06, -0.1902E-10,  &
  0.1572E+03,  0.2399E+00, -0.2281E-03, -0.1803E-06, -0.1992E-10,  &
  0.1587E+03,  0.2365E+00, -0.2329E-03, -0.1706E-06, -0.2140E-10,  &
  0.1598E+03,  0.2320E+00, -0.2399E-03, -0.1594E-06, -0.2061E-10,  &
  0.1609E+03,  0.2267E+00, -0.2483E-03, -0.1472E-06, -0.1832E-10,  &
  0.1627E+03,  0.2143E+00, -0.2673E-03, -0.1210E-06, -0.1061E-10,  &
  0.1658E+03,  0.1864E+00, -0.3111E-03, -0.6553E-07,  0.1225E-10,  &
  0.1605E+03,  0.2486E+00, -0.2108E-03, -0.2168E-06, -0.3851E-10,  &
  0.1623E+03,  0.2400E+00, -0.2216E-03, -0.2044E-06, -0.3598E-10,  &
  0.1644E+03,  0.2291E+00, -0.2383E-03, -0.1880E-06, -0.3001E-10,  &
  0.1657E+03,  0.2251E+00, -0.2416E-03, -0.1818E-06, -0.2622E-10,  &
  0.1668E+03,  0.2201E+00, -0.2473E-03, -0.1735E-06, -0.2007E-10,  &
  0.1677E+03,  0.2151E+00, -0.2565E-03, -0.1628E-06, -0.1213E-10,  &
  0.1695E+03,  0.2020E+00, -0.2746E-03, -0.1405E-06,  0.6886E-11,  &
  0.1721E+03,  0.1736E+00, -0.3185E-03, -0.9059E-07,  0.5228E-10,  &
  0.1726E+03,  0.2278E+00, -0.2223E-03, -0.2508E-06, -0.3486E-10,  &
  0.1738E+03,  0.2191E+00, -0.2330E-03, -0.2413E-06, -0.1979E-10,  &
  0.1754E+03,  0.2078E+00, -0.2480E-03, -0.2290E-06,  0.1130E-11,  &
  0.1766E+03,  0.2036E+00, -0.2495E-03, -0.2314E-06,  0.1731E-10,  &
  0.1775E+03,  0.1990E+00, -0.2542E-03, -0.2306E-06,  0.3540E-10,  &
  0.1783E+03,  0.1935E+00, -0.2611E-03, -0.2273E-06,  0.5486E-10,  &
  0.1797E+03,  0.1805E+00, -0.2770E-03, -0.2178E-06,  0.9708E-10,  &
  0.1819E+03,  0.1515E+00, -0.3167E-03, -0.1900E-06,  0.1874E-09,  &
  0.1914E+03,  0.1791E+00, -0.2066E-03, -0.4465E-06,  0.1845E-09,  &
  0.1920E+03,  0.1703E+00, -0.2127E-03, -0.4514E-06,  0.2244E-09,  &
  0.1931E+03,  0.1595E+00, -0.2202E-03, -0.4608E-06,  0.2775E-09,  &
  0.1941E+03,  0.1546E+00, -0.2147E-03, -0.4894E-06,  0.3267E-09,  &
  0.1947E+03,  0.1495E+00, -0.2136E-03, -0.5113E-06,  0.3757E-09,  &
  0.1954E+03,  0.1439E+00, -0.2161E-03, -0.5276E-06,  0.4244E-09,  &
  0.1963E+03,  0.1301E+00, -0.2227E-03, -0.5554E-06,  0.5233E-09,  &
  0.1977E+03,  0.1000E+00, -0.2475E-03, -0.5910E-06,  0.7192E-09   /
  data cuvb  (0:4, 449 : 504 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1444E+03,  0.2654E+00, -0.1849E-03, -0.2068E-06,  0.1304E-10,  &
  0.1478E+03,  0.2660E+00, -0.1909E-03, -0.2036E-06,  0.1709E-11,  &
  0.1511E+03,  0.2648E+00, -0.2063E-03, -0.1976E-06, -0.5700E-11,  &
  0.1536E+03,  0.2705E+00, -0.2115E-03, -0.1932E-06, -0.1321E-10,  &
  0.1554E+03,  0.2735E+00, -0.2217E-03, -0.1849E-06, -0.1641E-10,  &
  0.1570E+03,  0.2743E+00, -0.2343E-03, -0.1741E-06, -0.1743E-10,  &
  0.1596E+03,  0.2725E+00, -0.2658E-03, -0.1467E-06, -0.1504E-10,  &
  0.1638E+03,  0.2583E+00, -0.3328E-03, -0.8413E-07, -0.2927E-11,  &
  0.1452E+03,  0.2649E+00, -0.1859E-03, -0.2076E-06,  0.9608E-11,  &
  0.1486E+03,  0.2658E+00, -0.1927E-03, -0.2040E-06, -0.1071E-11,  &
  0.1521E+03,  0.2639E+00, -0.2078E-03, -0.1970E-06, -0.8525E-11,  &
  0.1544E+03,  0.2698E+00, -0.2131E-03, -0.1929E-06, -0.1554E-10,  &
  0.1563E+03,  0.2731E+00, -0.2238E-03, -0.1847E-06, -0.1823E-10,  &
  0.1577E+03,  0.2742E+00, -0.2371E-03, -0.1738E-06, -0.1863E-10,  &
  0.1604E+03,  0.2717E+00, -0.2668E-03, -0.1474E-06, -0.1594E-10,  &
  0.1644E+03,  0.2581E+00, -0.3352E-03, -0.8443E-07, -0.1937E-11,  &
  0.1478E+03,  0.2635E+00, -0.1898E-03, -0.2095E-06, -0.7166E-12,  &
  0.1510E+03,  0.2634E+00, -0.1963E-03, -0.2057E-06, -0.1072E-10,  &
  0.1542E+03,  0.2612E+00, -0.2125E-03, -0.1981E-06, -0.1642E-10,  &
  0.1566E+03,  0.2669E+00, -0.2176E-03, -0.1948E-06, -0.2243E-10,  &
  0.1584E+03,  0.2705E+00, -0.2292E-03, -0.1869E-06, -0.2367E-10,  &
  0.1598E+03,  0.2711E+00, -0.2415E-03, -0.1767E-06, -0.2317E-10,  &
  0.1623E+03,  0.2699E+00, -0.2745E-03, -0.1494E-06, -0.1710E-10,  &
  0.1664E+03,  0.2551E+00, -0.3419E-03, -0.8741E-07,  0.2673E-11,  &
  0.1527E+03,  0.2592E+00, -0.1960E-03, -0.2137E-06, -0.1922E-10,  &
  0.1558E+03,  0.2584E+00, -0.2036E-03, -0.2086E-06, -0.2617E-10,  &
  0.1588E+03,  0.2551E+00, -0.2208E-03, -0.1982E-06, -0.2810E-10,  &
  0.1609E+03,  0.2610E+00, -0.2258E-03, -0.1975E-06, -0.3136E-10,  &
  0.1625E+03,  0.2650E+00, -0.2377E-03, -0.1912E-06, -0.2993E-10,  &
  0.1639E+03,  0.2660E+00, -0.2507E-03, -0.1824E-06, -0.2648E-10,  &
  0.1663E+03,  0.2644E+00, -0.2824E-03, -0.1584E-06, -0.1498E-10,  &
  0.1699E+03,  0.2499E+00, -0.3500E-03, -0.1013E-06,  0.1707E-10,  &
  0.1609E+03,  0.2503E+00, -0.2071E-03, -0.2208E-06, -0.4096E-10,  &
  0.1631E+03,  0.2485E+00, -0.2150E-03, -0.2172E-06, -0.4131E-10,  &
  0.1655E+03,  0.2444E+00, -0.2329E-03, -0.2078E-06, -0.3570E-10,  &
  0.1676E+03,  0.2503E+00, -0.2380E-03, -0.2112E-06, -0.3257E-10,  &
  0.1690E+03,  0.2545E+00, -0.2498E-03, -0.2081E-06, -0.2519E-10,  &
  0.1704E+03,  0.2554E+00, -0.2628E-03, -0.2020E-06, -0.1547E-10,  &
  0.1725E+03,  0.2540E+00, -0.2957E-03, -0.1815E-06,  0.8773E-11,  &
  0.1759E+03,  0.2390E+00, -0.3640E-03, -0.1313E-06,  0.6735E-10,  &
  0.1729E+03,  0.2299E+00, -0.2197E-03, -0.2558E-06, -0.3577E-10,  &
  0.1744E+03,  0.2269E+00, -0.2285E-03, -0.2556E-06, -0.2112E-10,  &
  0.1764E+03,  0.2218E+00, -0.2435E-03, -0.2529E-06,  0.1248E-11,  &
  0.1781E+03,  0.2286E+00, -0.2480E-03, -0.2683E-06,  0.1986E-10,  &
  0.1794E+03,  0.2327E+00, -0.2584E-03, -0.2750E-06,  0.4142E-10,  &
  0.1806E+03,  0.2341E+00, -0.2704E-03, -0.2779E-06,  0.6516E-10,  &
  0.1826E+03,  0.2323E+00, -0.2999E-03, -0.2741E-06,  0.1169E-09,  &
  0.1853E+03,  0.2175E+00, -0.3642E-03, -0.2522E-06,  0.2299E-09,  &
  0.1915E+03,  0.1804E+00, -0.2045E-03, -0.4525E-06,  0.1864E-09,  &
  0.1924E+03,  0.1760E+00, -0.2095E-03, -0.4687E-06,  0.2310E-09,  &
  0.1940E+03,  0.1707E+00, -0.2142E-03, -0.4968E-06,  0.2935E-09,  &
  0.1955E+03,  0.1769E+00, -0.2092E-03, -0.5520E-06,  0.3583E-09,  &
  0.1966E+03,  0.1806E+00, -0.2117E-03, -0.5919E-06,  0.4212E-09,  &
  0.1976E+03,  0.1820E+00, -0.2186E-03, -0.6222E-06,  0.4830E-09,  &
  0.1991E+03,  0.1795E+00, -0.2369E-03, -0.6685E-06,  0.6067E-09,  &
  0.2012E+03,  0.1631E+00, -0.2814E-03, -0.7324E-06,  0.8532E-09   /
  data cuvb  (0:4, 505 : 560 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1430E+03,  0.2594E+00, -0.1929E-03, -0.2002E-06,  0.2038E-10,  &
  0.1452E+03,  0.2514E+00, -0.2082E-03, -0.1865E-06,  0.1729E-10,  &
  0.1475E+03,  0.2417E+00, -0.2281E-03, -0.1699E-06,  0.1433E-10,  &
  0.1487E+03,  0.2341E+00, -0.2350E-03, -0.1527E-06,  0.1015E-10,  &
  0.1497E+03,  0.2268E+00, -0.2437E-03, -0.1354E-06,  0.7334E-11,  &
  0.1506E+03,  0.2190E+00, -0.2524E-03, -0.1180E-06,  0.4998E-11,  &
  0.1523E+03,  0.2038E+00, -0.2724E-03, -0.8244E-07,  0.2219E-11,  &
  0.1555E+03,  0.1711E+00, -0.3105E-03, -0.1443E-07, -0.4593E-13,  &
  0.1439E+03,  0.2585E+00, -0.1937E-03, -0.2005E-06,  0.1683E-10,  &
  0.1461E+03,  0.2504E+00, -0.2090E-03, -0.1862E-06,  0.1389E-10,  &
  0.1485E+03,  0.2408E+00, -0.2296E-03, -0.1687E-06,  0.1140E-10,  &
  0.1496E+03,  0.2335E+00, -0.2371E-03, -0.1516E-06,  0.7801E-11,  &
  0.1507E+03,  0.2259E+00, -0.2453E-03, -0.1343E-06,  0.5107E-11,  &
  0.1516E+03,  0.2182E+00, -0.2539E-03, -0.1171E-06,  0.3083E-11,  &
  0.1532E+03,  0.2027E+00, -0.2732E-03, -0.8197E-07,  0.7466E-12,  &
  0.1559E+03,  0.1743E+00, -0.3211E-03, -0.8330E-08,  0.0000E+00,  &
  0.1467E+03,  0.2566E+00, -0.1977E-03, -0.2015E-06,  0.6652E-11,  &
  0.1487E+03,  0.2483E+00, -0.2137E-03, -0.1864E-06,  0.4737E-11,  &
  0.1509E+03,  0.2377E+00, -0.2337E-03, -0.1678E-06,  0.2785E-11,  &
  0.1520E+03,  0.2300E+00, -0.2406E-03, -0.1509E-06,  0.0000E+00,  &
  0.1530E+03,  0.2222E+00, -0.2486E-03, -0.1338E-06, -0.1718E-11,  &
  0.1539E+03,  0.2149E+00, -0.2582E-03, -0.1163E-06, -0.2435E-11,  &
  0.1555E+03,  0.1991E+00, -0.2776E-03, -0.8107E-07, -0.2680E-11,  &
  0.1585E+03,  0.1660E+00, -0.3158E-03, -0.1306E-07,  0.5991E-12,  &
  0.1517E+03,  0.2520E+00, -0.2046E-03, -0.2039E-06, -0.1151E-10,  &
  0.1535E+03,  0.2431E+00, -0.2211E-03, -0.1862E-06, -0.1128E-10,  &
  0.1558E+03,  0.2308E+00, -0.2404E-03, -0.1645E-06, -0.1118E-10,  &
  0.1568E+03,  0.2236E+00, -0.2482E-03, -0.1485E-06, -0.1138E-10,  &
  0.1578E+03,  0.2153E+00, -0.2548E-03, -0.1328E-06, -0.1118E-10,  &
  0.1585E+03,  0.2078E+00, -0.2643E-03, -0.1161E-06, -0.9710E-11,  &
  0.1600E+03,  0.1921E+00, -0.2833E-03, -0.8265E-07, -0.5572E-11,  &
  0.1628E+03,  0.1586E+00, -0.3206E-03, -0.1802E-07,  0.6647E-11,  &
  0.1599E+03,  0.2428E+00, -0.2165E-03, -0.2077E-06, -0.3374E-10,  &
  0.1614E+03,  0.2323E+00, -0.2312E-03, -0.1901E-06, -0.2959E-10,  &
  0.1632E+03,  0.2194E+00, -0.2505E-03, -0.1680E-06, -0.2355E-10,  &
  0.1641E+03,  0.2116E+00, -0.2572E-03, -0.1536E-06, -0.1946E-10,  &
  0.1648E+03,  0.2041E+00, -0.2661E-03, -0.1381E-06, -0.1426E-10,  &
  0.1656E+03,  0.1954E+00, -0.2732E-03, -0.1234E-06, -0.8576E-11,  &
  0.1670E+03,  0.1788E+00, -0.2912E-03, -0.9219E-07,  0.4739E-11,  &
  0.1693E+03,  0.1447E+00, -0.3291E-03, -0.3018E-07,  0.3538E-10,  &
  0.1719E+03,  0.2226E+00, -0.2315E-03, -0.2354E-06, -0.3204E-10,  &
  0.1730E+03,  0.2114E+00, -0.2441E-03, -0.2197E-06, -0.1775E-10,  &
  0.1745E+03,  0.1973E+00, -0.2606E-03, -0.2003E-06,  0.9897E-12,  &
  0.1752E+03,  0.1897E+00, -0.2672E-03, -0.1901E-06,  0.1451E-10,  &
  0.1758E+03,  0.1825E+00, -0.2761E-03, -0.1783E-06,  0.2875E-10,  &
  0.1764E+03,  0.1742E+00, -0.2834E-03, -0.1675E-06,  0.4382E-10,  &
  0.1775E+03,  0.1569E+00, -0.2986E-03, -0.1454E-06,  0.7586E-10,  &
  0.1794E+03,  0.1222E+00, -0.3331E-03, -0.9910E-07,  0.1432E-09,  &
  0.1909E+03,  0.1742E+00, -0.2210E-03, -0.4143E-06,  0.1747E-09,  &
  0.1912E+03,  0.1645E+00, -0.2327E-03, -0.4063E-06,  0.2086E-09,  &
  0.1921E+03,  0.1512E+00, -0.2443E-03, -0.4009E-06,  0.2532E-09,  &
  0.1926E+03,  0.1435E+00, -0.2479E-03, -0.4041E-06,  0.2890E-09,  &
  0.1930E+03,  0.1356E+00, -0.2523E-03, -0.4063E-06,  0.3254E-09,  &
  0.1934E+03,  0.1274E+00, -0.2576E-03, -0.4070E-06,  0.3621E-09,  &
  0.1940E+03,  0.1106E+00, -0.2697E-03, -0.4066E-06,  0.4367E-09,  &
  0.1950E+03,  0.7636E-01, -0.2981E-03, -0.3996E-06,  0.5854E-09   /
  data cuvb  (0:4, 561 : 616 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1431E+03,  0.2600E+00, -0.1926E-03, -0.2007E-06,  0.1997E-10,  &
  0.1455E+03,  0.2531E+00, -0.2052E-03, -0.1888E-06,  0.1481E-10,  &
  0.1481E+03,  0.2442E+00, -0.2228E-03, -0.1742E-06,  0.1027E-10,  &
  0.1495E+03,  0.2389E+00, -0.2283E-03, -0.1598E-06,  0.5046E-11,  &
  0.1509E+03,  0.2326E+00, -0.2348E-03, -0.1450E-06,  0.1300E-11,  &
  0.1518E+03,  0.2270E+00, -0.2443E-03, -0.1294E-06, -0.5367E-12,  &
  0.1539E+03,  0.2127E+00, -0.2620E-03, -0.9808E-07, -0.2864E-11,  &
  0.1572E+03,  0.1838E+00, -0.3040E-03, -0.3431E-07, -0.8917E-12,  &
  0.1440E+03,  0.2593E+00, -0.1935E-03, -0.2012E-06,  0.1651E-10,  &
  0.1465E+03,  0.2522E+00, -0.2062E-03, -0.1886E-06,  0.1151E-10,  &
  0.1491E+03,  0.2434E+00, -0.2245E-03, -0.1731E-06,  0.7485E-11,  &
  0.1505E+03,  0.2385E+00, -0.2306E-03, -0.1589E-06,  0.2874E-11,  &
  0.1517E+03,  0.2318E+00, -0.2363E-03, -0.1443E-06, -0.8216E-12,  &
  0.1528E+03,  0.2259E+00, -0.2454E-03, -0.1289E-06, -0.2464E-11,  &
  0.1548E+03,  0.2120E+00, -0.2636E-03, -0.9759E-07, -0.3951E-11,  &
  0.1581E+03,  0.1829E+00, -0.3052E-03, -0.3430E-07, -0.6749E-12,  &
  0.1468E+03,  0.2570E+00, -0.1968E-03, -0.2020E-06,  0.5932E-11,  &
  0.1490E+03,  0.2496E+00, -0.2100E-03, -0.1890E-06,  0.1999E-11,  &
  0.1513E+03,  0.2415E+00, -0.2307E-03, -0.1724E-06,  0.0000E+00,  &
  0.1528E+03,  0.2351E+00, -0.2343E-03, -0.1587E-06, -0.4671E-11,  &
  0.1540E+03,  0.2289E+00, -0.2410E-03, -0.1443E-06, -0.6876E-11,  &
  0.1551E+03,  0.2223E+00, -0.2489E-03, -0.1293E-06, -0.7781E-11,  &
  0.1570E+03,  0.2084E+00, -0.2676E-03, -0.9820E-07, -0.6827E-11,  &
  0.1602E+03,  0.1785E+00, -0.3087E-03, -0.3533E-07,  0.1209E-11,  &
  0.1517E+03,  0.2528E+00, -0.2043E-03, -0.2046E-06, -0.1189E-10,  &
  0.1538E+03,  0.2445E+00, -0.2176E-03, -0.1893E-06, -0.1375E-10,  &
  0.1563E+03,  0.2339E+00, -0.2364E-03, -0.1698E-06, -0.1407E-10,  &
  0.1576E+03,  0.2280E+00, -0.2403E-03, -0.1579E-06, -0.1590E-10,  &
  0.1587E+03,  0.2220E+00, -0.2472E-03, -0.1448E-06, -0.1555E-10,  &
  0.1595E+03,  0.2161E+00, -0.2561E-03, -0.1306E-06, -0.1379E-10,  &
  0.1613E+03,  0.2020E+00, -0.2738E-03, -0.1019E-06, -0.8134E-11,  &
  0.1642E+03,  0.1719E+00, -0.3143E-03, -0.4278E-07,  0.9549E-11,  &
  0.1599E+03,  0.2436E+00, -0.2164E-03, -0.2085E-06, -0.3403E-10,  &
  0.1615E+03,  0.2341E+00, -0.2285E-03, -0.1937E-06, -0.3125E-10,  &
  0.1635E+03,  0.2224E+00, -0.2463E-03, -0.1745E-06, -0.2567E-10,  &
  0.1647E+03,  0.2165E+00, -0.2503E-03, -0.1649E-06, -0.2221E-10,  &
  0.1656E+03,  0.2104E+00, -0.2567E-03, -0.1538E-06, -0.1686E-10,  &
  0.1665E+03,  0.2038E+00, -0.2647E-03, -0.1416E-06, -0.1022E-10,  &
  0.1681E+03,  0.1893E+00, -0.2823E-03, -0.1156E-06,  0.5777E-11,  &
  0.1706E+03,  0.1586E+00, -0.3226E-03, -0.6101E-07,  0.4393E-10,  &
  0.1721E+03,  0.2226E+00, -0.2298E-03, -0.2371E-06, -0.3238E-10,  &
  0.1732E+03,  0.2125E+00, -0.2407E-03, -0.2249E-06, -0.1825E-10,  &
  0.1747E+03,  0.2000E+00, -0.2559E-03, -0.2093E-06,  0.1034E-11,  &
  0.1757E+03,  0.1946E+00, -0.2594E-03, -0.2064E-06,  0.1561E-10,  &
  0.1765E+03,  0.1885E+00, -0.2649E-03, -0.2013E-06,  0.3166E-10,  &
  0.1772E+03,  0.1816E+00, -0.2710E-03, -0.1955E-06,  0.4893E-10,  &
  0.1784E+03,  0.1675E+00, -0.2874E-03, -0.1798E-06,  0.8587E-10,  &
  0.1806E+03,  0.1361E+00, -0.3242E-03, -0.1441E-06,  0.1649E-09,  &
  0.1909E+03,  0.1744E+00, -0.2199E-03, -0.4165E-06,  0.1753E-09,  &
  0.1914E+03,  0.1650E+00, -0.2282E-03, -0.4150E-06,  0.2116E-09,  &
  0.1923E+03,  0.1538E+00, -0.2389E-03, -0.4157E-06,  0.2593E-09,  &
  0.1931E+03,  0.1471E+00, -0.2351E-03, -0.4353E-06,  0.3026E-09,  &
  0.1937E+03,  0.1405E+00, -0.2353E-03, -0.4494E-06,  0.3458E-09,  &
  0.1942E+03,  0.1340E+00, -0.2394E-03, -0.4584E-06,  0.3885E-09,  &
  0.1951E+03,  0.1187E+00, -0.2470E-03, -0.4751E-06,  0.4762E-09,  &
  0.1962E+03,  0.8739E-01, -0.2731E-03, -0.4917E-06,  0.6494E-09   /
  data cuvb  (0:4, 617 : 672 )/ & !8 cldtau ,7 sza , 3cldhgt  ,2 o3profileindex  , 2sfcalb  
  0.1434E+03,  0.2612E+00, -0.1893E-03, -0.2024E-06,  0.1733E-10,  &
  0.1466E+03,  0.2597E+00, -0.1966E-03, -0.1967E-06,  0.7293E-11,  &
  0.1500E+03,  0.2557E+00, -0.2108E-03, -0.1884E-06, -0.3524E-12,  &
  0.1523E+03,  0.2580E+00, -0.2133E-03, -0.1823E-06, -0.8677E-11,  &
  0.1540E+03,  0.2588E+00, -0.2210E-03, -0.1735E-06, -0.1269E-10,  &
  0.1556E+03,  0.2580E+00, -0.2311E-03, -0.1628E-06, -0.1445E-10,  &
  0.1582E+03,  0.2538E+00, -0.2566E-03, -0.1375E-06, -0.1358E-10,  &
  0.1622E+03,  0.2376E+00, -0.3150E-03, -0.7993E-07, -0.2784E-11,  &
  0.1444E+03,  0.2604E+00, -0.1901E-03, -0.2029E-06,  0.1379E-10,  &
  0.1475E+03,  0.2591E+00, -0.1981E-03, -0.1968E-06,  0.4297E-11,  &
  0.1508E+03,  0.2550E+00, -0.2127E-03, -0.1876E-06, -0.2933E-11,  &
  0.1532E+03,  0.2575E+00, -0.2154E-03, -0.1819E-06, -0.1079E-10,  &
  0.1549E+03,  0.2583E+00, -0.2231E-03, -0.1732E-06, -0.1444E-10,  &
  0.1563E+03,  0.2579E+00, -0.2336E-03, -0.1626E-06, -0.1574E-10,  &
  0.1590E+03,  0.2531E+00, -0.2579E-03, -0.1379E-06, -0.1438E-10,  &
  0.1630E+03,  0.2370E+00, -0.3166E-03, -0.8062E-07, -0.1852E-11,  &
  0.1471E+03,  0.2586E+00, -0.1943E-03, -0.2042E-06,  0.3689E-11,  &
  0.1501E+03,  0.2565E+00, -0.2018E-03, -0.1978E-06, -0.5248E-11,  &
  0.1531E+03,  0.2518E+00, -0.2167E-03, -0.1881E-06, -0.1120E-10,  &
  0.1553E+03,  0.2547E+00, -0.2204E-03, -0.1831E-06, -0.1747E-10,  &
  0.1569E+03,  0.2554E+00, -0.2275E-03, -0.1751E-06, -0.2013E-10,  &
  0.1584E+03,  0.2548E+00, -0.2380E-03, -0.1650E-06, -0.2018E-10,  &
  0.1610E+03,  0.2500E+00, -0.2628E-03, -0.1407E-06, -0.1596E-10,  &
  0.1649E+03,  0.2330E+00, -0.3203E-03, -0.8512E-07,  0.2593E-11,  &
  0.1520E+03,  0.2546E+00, -0.2018E-03, -0.2072E-06, -0.1406E-10,  &
  0.1548E+03,  0.2511E+00, -0.2087E-03, -0.1996E-06, -0.2090E-10,  &
  0.1578E+03,  0.2453E+00, -0.2244E-03, -0.1873E-06, -0.2333E-10,  &
  0.1598E+03,  0.2480E+00, -0.2271E-03, -0.1849E-06, -0.2709E-10,  &
  0.1613E+03,  0.2493E+00, -0.2352E-03, -0.1787E-06, -0.2669E-10,  &
  0.1626E+03,  0.2493E+00, -0.2462E-03, -0.1701E-06, -0.2392E-10,  &
  0.1649E+03,  0.2446E+00, -0.2707E-03, -0.1489E-06, -0.1401E-10,  &
  0.1686E+03,  0.2283E+00, -0.3297E-03, -0.9723E-07,  0.1632E-10,  &
  0.1601E+03,  0.2452E+00, -0.2129E-03, -0.2122E-06, -0.3630E-10,  &
  0.1623E+03,  0.2405E+00, -0.2197E-03, -0.2062E-06, -0.3688E-10,  &
  0.1647E+03,  0.2336E+00, -0.2347E-03, -0.1955E-06, -0.3232E-10,  &
  0.1665E+03,  0.2371E+00, -0.2386E-03, -0.1968E-06, -0.2953E-10,  &
  0.1680E+03,  0.2384E+00, -0.2465E-03, -0.1938E-06, -0.2314E-10,  &
  0.1691E+03,  0.2379E+00, -0.2565E-03, -0.1883E-06, -0.1434E-10,  &
  0.1714E+03,  0.2331E+00, -0.2809E-03, -0.1721E-06,  0.8319E-11,  &
  0.1745E+03,  0.2168E+00, -0.3412E-03, -0.1270E-06,  0.6450E-10,  &
  0.1723E+03,  0.2240E+00, -0.2259E-03, -0.2427E-06, -0.3343E-10,  &
  0.1738E+03,  0.2187E+00, -0.2332E-03, -0.2405E-06, -0.1972E-10,  &
  0.1757E+03,  0.2112E+00, -0.2461E-03, -0.2358E-06,  0.1163E-11,  &
  0.1773E+03,  0.2141E+00, -0.2463E-03, -0.2500E-06,  0.1858E-10,  &
  0.1785E+03,  0.2157E+00, -0.2525E-03, -0.2574E-06,  0.3897E-10,  &
  0.1796E+03,  0.2158E+00, -0.2623E-03, -0.2601E-06,  0.6137E-10,  &
  0.1814E+03,  0.2115E+00, -0.2847E-03, -0.2598E-06,  0.1111E-09,  &
  0.1842E+03,  0.1941E+00, -0.3382E-03, -0.2451E-06,  0.2208E-09,  &
  0.1909E+03,  0.1758E+00, -0.2169E-03, -0.4236E-06,  0.1775E-09,  &
  0.1918E+03,  0.1694E+00, -0.2197E-03, -0.4379E-06,  0.2198E-09,  &
  0.1931E+03,  0.1619E+00, -0.2231E-03, -0.4614E-06,  0.2782E-09,  &
  0.1945E+03,  0.1646E+00, -0.2150E-03, -0.5121E-06,  0.3386E-09,  &
  0.1956E+03,  0.1652E+00, -0.2128E-03, -0.5515E-06,  0.3984E-09,  &
  0.1966E+03,  0.1641E+00, -0.2141E-03, -0.5838E-06,  0.4582E-09,  &
  0.1980E+03,  0.1591E+00, -0.2250E-03, -0.6334E-06,  0.5781E-09,  &
  0.2001E+03,  0.1398E+00, -0.2574E-03, -0.7049E-06,  0.8185E-09   /
contains
!------------------------------------------------------------------------
	subroutine tf_table(n1,n2,ib)
	implicit none
	integer n1,n2,i,ii
	logical ib(n1,n2)
	if(  uvbinitcldy ) return
	do i=1,n2
	do ii=1,n1
	ib(ii,i)=btest(i-1,ii-1)
	enddo
!	print*,i,ib(1:n1,i)
	enddo
	uvbinitcldy = .true.
	return
	end subroutine tf_table
!-----------------------------------------------------------------------
	integer function ilui(iva)
	implicit none
	integer i,k
	integer  iva(nv)
	integer  mva(nv)

	mva(1)=nva(1)
	do i=2,nv
	 mva(i)=mva(i-1)*nva(i)
	enddo

	k= iva(1)
	do i=2,nv
	k= k+ (iva(i)-1)*mva(i-1)
	enddo

	ilui=k
	return
	end function ilui
!----------------------------------------------------------------
subroutine uvb_lut_cloudy
implicit none

	real B_vt, swx,wx,rmin,rmax,B_value
	integer i,j,ik,k,iv,in
	integer  iva(nv,2**nv)
	
	real wb(nv),wt(nv),rva(nv),val(nv)
	integer ibase(nv),itop(nv)
	real o3x(5)

	o3x(1)=uvco%o3
	do i=2,5
	 o3x(i) = o3x(i-1)*o3x(1)
 	enddo

	val(1) =  uvco%cldtau	!Cldtau 1-99..
	val(2) =  acos(uvco%u0) *(180.0/3.14159)	! Cos Sol to SZA
	val(3) =  uvco%cldhgt	! Cld Height KM
	val(4) =  uvco%p03_20km	! % O3 below 20km
	val(5) =  uvco%salb		! Spectral Surface Albedo in UV

	 call tf_table(nv,2**nv,ichoose)

!--------------------
	 VSET : do iv=1,nv 
	rmin = anodes(1,iv)
	rmax = anodes(nva(iv),iv)

	if (val(iv) <= rmin )then 
	  rva(iv) = 1
	elseif (val(iv) >= rmax ) then
	  rva(iv) = nva(iv)
	else

	FNODES : do in = 1,nva(iv)-1
	if( val(iv) >= anodes(in,iv) .and. val(iv) < anodes(in+1,iv)) & 
     	rva(iv)= in+( val(iv)-anodes(in,iv)) /                        &
                    (anodes(in+1,iv)-anodes(in,iv))
	enddo FNODES

	endif

!	print*,iv,rva(iv)
	enddo VSET
!---------------------

	 ibase = floor(rva)
	 where( ibase < 1) ibase=1

	 itop= ceiling(rva)
	 where( itop > nva) itop=nva

	wb=1.0-(rva-ibase)
	wt=1.0-wb
	
!	print'(A10,10f5.1)','Exact',rva(1:nv)
!	print'(A10,10I5)','BASE',ibase
!	print'(A10,10I5)','TOP',itop
!	print'(A10,10f5.1)','Wb',wb	
!	print'(A10,10f5.1)','Wt',wt

	swx=0 ;  B_value =0 ; ik=0

	NODE : do j=1,2**nv
	wx=1.0

	 DIMENSION: do i=1,nv

	 if( ichoose(i,j) ) then
	  iva(i,j) = itop(i)
	  wx=wx*wt(i)
	 else
	  iva(i,j) = ibase(i)
	  wx=wx*wb(i)
	 endif

	 enddo DIMENSION
	
	 if( wx > 0 ) then
	 ik=ik+1
	 k = ilui(iva(1,j))
   
	 B_vt  = cuvb(0,k) + &
		  cuvb(1,k)*o3x(1) + cuvb(2,k)*o3x(2) + &
		  cuvb(3,k)*o3x(3) + cuvb(4,k)*o3x(4)  !!!!!cuvb(5,k)*o3x(5)!UVB
	 swx       = swx  +               wx

	 B_value      = B_value + B_vt * wx

!	print'(3I4,3f10.5,10I4)',ik,j,k,B_vt ,wx,swx,iva(1:nv,j)
!	if (swx >= 0.9999 )exit
	endif

	enddo NODE

	uvco%cr_uvb = 100. / (B_value/swx)	    
	uvco%uvb = uvco%swdn_b5 * uvco%cr_uvb
	
	return

	end subroutine uvb_lut_cloudy

END MODULE UVB_CORRECTION_CLOUDY


!=====================================================
MODULE UVA_CORRECTION_CLOUDY
USE WSU_TYPEDEF ,only : uvco
implicit none
private
public ::  uvco,uva_lut_cloudy

integer ,parameter :: nv = 3  ,mxn =8 
! nv = # of Variables in look up table.
! mxn = Max # of nodes for any single variable
! nva = # of nodes for each variables
! anodes = The values at each node in the table; for all variables
 
integer nva(nv)
real,save:: anodes(mxn,nv)
logical ,save:: ichoose(nv,2**nv), uvainitcldy = .false.

data nva  /2,7,8/
! 1-2 Sfcalb in band 6
data anodes(1:2,1) /0.1,0.9/
!!1-7 sza
data anodes(1:7,2) /  0. , 10. , 20. , 30. , 40. , 50. , 60./
!!! 1-8 CLDTAU
data anodes(1:8,3) /1.000,5.000,10.000,20.000,30.000,40.000,60.000,99.000 /


real cuva(2*7*8)
real cery(0:3,2*7*8)
!!2  sfcalb  0.061    0.920
!!7    SZA   0.000  10.000  20.000  30.000  40.000  50.000  60.000
!!8 CLDTAU   1.000   5.000  10.000  20.000  30.000  40.000  60.000  99.000
 
 data cuva / & ! 2 sfcalbedo , 7 sza , 8 cldtau , 
 37.122, 39.053,  &
 37.097, 39.026,  &
 37.037, 38.963,  &
 36.933, 38.861,  &
 36.778, 38.709,  &
 36.603, 38.531,  &
 36.458, 38.373,  &
 37.169, 38.837,  &
 37.153, 38.818,  &
 37.114, 38.778,  &
 37.049, 38.713,  &
 36.958, 38.626,  &
 36.867, 38.534,  &
 36.812, 38.474,  &
 37.261, 38.696,  &
 37.249, 38.685,  &
 37.222, 38.658,  &
 37.181, 38.614,  &
 37.120, 38.559,  &
 37.066, 38.505,  &
 37.043, 38.481,  &
 37.390, 38.569,  &
 37.381, 38.560,  &
 37.361, 38.540,  &
 37.331, 38.509,  &
 37.287, 38.471,  &
 37.252, 38.436,  &
 37.248, 38.430,  &
 37.504, 38.454,  &
 37.497, 38.447,  &
 37.482, 38.431,  &
 37.460, 38.408,  &
 37.426, 38.379,  &
 37.402, 38.356,  &
 37.408, 38.360,  &
 37.602, 38.350,  &
 37.596, 38.344,  &
 37.584, 38.330,  &
 37.567, 38.312,  &
 37.540, 38.290,  &
 37.524, 38.275,  &
 37.536, 38.286,  &
 37.694, 38.235,  &
 37.687, 38.230,  &
 37.677, 38.218,  &
 37.663, 38.204,  &
 37.642, 38.186,  &
 37.631, 38.176,  &
 37.649, 38.192,  &
 37.778, 38.099,  &
 37.772, 38.094,  &
 37.764, 38.084,  &
 37.752, 38.072,  &
 37.735, 38.058,  &
 37.728, 38.052,  &
 37.750, 38.071/
  data cery(0:3,1:56) / & ! 3rdOrd Poly  7 sza 8 cldtau
  0.3121E+02, -0.1226E+00,  0.2761E-03, -0.2184E-06,  &
  0.3093E+02, -0.1216E+00,  0.2748E-03, -0.2175E-06,  &
  0.3003E+02, -0.1178E+00,  0.2681E-03, -0.2118E-06,  &
  0.2860E+02, -0.1122E+00,  0.2602E-03, -0.2059E-06,  &
  0.2640E+02, -0.1022E+00,  0.2425E-03, -0.1898E-06,  &
  0.2356E+02, -0.8845E-01,  0.2188E-03, -0.1666E-06,  &
  0.2001E+02, -0.6929E-01,  0.1843E-03, -0.1255E-06,  &
  0.3074E+02, -0.1204E+00,  0.2720E-03, -0.2149E-06,  &
  0.3052E+02, -0.1199E+00,  0.2722E-03, -0.2156E-06,  &
  0.2961E+02, -0.1158E+00,  0.2642E-03, -0.2083E-06,  &
  0.2825E+02, -0.1105E+00,  0.2568E-03, -0.2027E-06,  &
  0.2619E+02, -0.1014E+00,  0.2414E-03, -0.1890E-06,  &
  0.2345E+02, -0.8815E-01,  0.2184E-03, -0.1662E-06,  &
  0.2000E+02, -0.6969E-01,  0.1855E-03, -0.1271E-06,  &
  0.3042E+02, -0.1191E+00,  0.2698E-03, -0.2131E-06,  &
  0.3020E+02, -0.1185E+00,  0.2698E-03, -0.2136E-06,  &
  0.2937E+02, -0.1150E+00,  0.2639E-03, -0.2085E-06,  &
  0.2798E+02, -0.1091E+00,  0.2542E-03, -0.2003E-06,  &
  0.2598E+02, -0.1002E+00,  0.2390E-03, -0.1866E-06,  &
  0.2326E+02, -0.8688E-01,  0.2152E-03, -0.1628E-06,  &
  0.1987E+02, -0.6894E-01,  0.1838E-03, -0.1251E-06,  &
  0.3003E+02, -0.1175E+00,  0.2675E-03, -0.2113E-06,  &
  0.2977E+02, -0.1164E+00,  0.2657E-03, -0.2098E-06,  &
  0.2902E+02, -0.1135E+00,  0.2616E-03, -0.2067E-06,  &
  0.2768E+02, -0.1079E+00,  0.2525E-03, -0.1989E-06,  &
  0.2570E+02, -0.9894E-01,  0.2370E-03, -0.1846E-06,  &
  0.2309E+02, -0.8631E-01,  0.2151E-03, -0.1626E-06,  &
  0.1971E+02, -0.6801E-01,  0.1821E-03, -0.1225E-06,  &
  0.2972E+02, -0.1160E+00,  0.2647E-03, -0.2087E-06,  &
  0.2952E+02, -0.1155E+00,  0.2646E-03, -0.2091E-06,  &
  0.2874E+02, -0.1123E+00,  0.2594E-03, -0.2047E-06,  &
  0.2739E+02, -0.1063E+00,  0.2489E-03, -0.1954E-06,  &
  0.2551E+02, -0.9807E-01,  0.2358E-03, -0.1836E-06,  &
  0.2291E+02, -0.8534E-01,  0.2134E-03, -0.1607E-06,  &
  0.1957E+02, -0.6724E-01,  0.1808E-03, -0.1206E-06,  &
  0.2949E+02, -0.1149E+00,  0.2627E-03, -0.2070E-06,  &
  0.2928E+02, -0.1143E+00,  0.2626E-03, -0.2074E-06,  &
  0.2852E+02, -0.1112E+00,  0.2573E-03, -0.2028E-06,  &
  0.2721E+02, -0.1055E+00,  0.2481E-03, -0.1948E-06,  &
  0.2532E+02, -0.9701E-01,  0.2337E-03, -0.1816E-06,  &
  0.2270E+02, -0.8388E-01,  0.2098E-03, -0.1568E-06,  &
  0.1946E+02, -0.6652E-01,  0.1793E-03, -0.1185E-06,  &
  0.2916E+02, -0.1136E+00,  0.2612E-03, -0.2060E-06,  &
  0.2890E+02, -0.1125E+00,  0.2593E-03, -0.2043E-06,  &
  0.2819E+02, -0.1097E+00,  0.2551E-03, -0.2009E-06,  &
  0.2691E+02, -0.1042E+00,  0.2461E-03, -0.1931E-06,  &
  0.2503E+02, -0.9550E-01,  0.2310E-03, -0.1788E-06,  &
  0.2257E+02, -0.8366E-01,  0.2112E-03, -0.1582E-06,  &
  0.1929E+02, -0.6538E-01,  0.1772E-03, -0.1152E-06,  &
  0.2859E+02, -0.1109E+00,  0.2563E-03, -0.2015E-06,  &
  0.2842E+02, -0.1106E+00,  0.2570E-03, -0.2027E-06,  &
  0.2768E+02, -0.1073E+00,  0.2512E-03, -0.1973E-06,  &
  0.2644E+02, -0.1018E+00,  0.2418E-03, -0.1889E-06,  &
  0.2461E+02, -0.9324E-01,  0.2268E-03, -0.1744E-06,  &
  0.2220E+02, -0.8135E-01,  0.2064E-03, -0.1525E-06,  &
  0.1906E+02, -0.6402E-01,  0.1752E-03, -0.1117E-06   /
contains
!------------------------------------------------------------------------
	subroutine tf_table(n1,n2,ib)
	implicit none
	integer n1,n2,i,ii
	logical ib(n1,n2)
	if(  uvainitcldy ) return
	do i=1,n2
	do ii=1,n1
	ib(ii,i)=btest(i-1,ii-1)
	enddo
!	print*,i,ib(1:n1,i)
	enddo
	uvainitcldy = .true.

	cery(0:3,57:112) = cery(0:3,1:56) ! Duplicate to use same index no sfcalb dependence.

	return
	end subroutine tf_table
!-----------------------------------------------------------------------
	integer function ilui(iva)
	implicit none
	integer i,k
	integer  iva(nv)
	integer  mva(nv)

	mva(1)=nva(1)
	do i=2,nv
	 mva(i)=mva(i-1)*nva(i)
	enddo

	k= iva(1)
	do i=2,nv
	k= k+ (iva(i)-1)*mva(i-1)
	enddo

	ilui=k
	return
	end function ilui
!----------------------------------------------------------------
subroutine uva_lut_cloudy
implicit none
	real A_vt,A_value,E_vt,E_value
	real swx,wx,rmin,rmax

	integer i,j,ik,k,iv,in
	integer  iva(nv,2**nv)
	
	real wb(nv),wt(nv),rva(nv),val(nv)
	integer ibase(nv),itop(nv)
	
	real o3x(3)

	o3x(1)=uvco%o3
	do i=2,3
	 o3x(i) = o3x(i-1)*o3x(1)
 	enddo


	val(1) =  uvco%salb		! Spectral Surface Albedo in UV
	val(2) =  acos(uvco%u0)*(180.0/3.14159)	! Cos Sol to SZA
	val(3) =  uvco%cldtau       !! Cloudtau
	
	 call tf_table(nv,2**nv,ichoose)
!--------------------
	 VSET : do iv=1,nv 
	rmin = anodes(1,iv)
	rmax = anodes(nva(iv),iv)

	if (val(iv) <= rmin )then 
	  rva(iv) = 1
	elseif (val(iv) >= rmax ) then
	  rva(iv) = nva(iv)
	else

	FNODES : do in = 1,nva(iv)-1
	if( val(iv) >= anodes(in,iv) .and. val(iv) < anodes(in+1,iv)) & 
     	rva(iv)= in+( val(iv)-anodes(in,iv)) /                        &
                    (anodes(in+1,iv)-anodes(in,iv))
	enddo FNODES

	endif

!	print*,iv,rva(iv)
	enddo VSET
!---------------------

	 ibase = floor(rva)
	 where( ibase < 1) ibase=1

	 itop= ceiling(rva)
	 where( itop > nva) itop=nva

	wb=1.0-(rva-ibase)
	wt=1.0-wb
	
!	print'(A10,10f5.1)','Exact',rva(1:nv)
!	print'(A10,10I5)','BASE',ibase
!	print'(A10,10I5)','TOP',itop
!	print'(A10,10f5.1)','Wb',wb	
!	print'(A10,10f5.1)','Wt',wt

	swx=0 ;  A_value =0 ;E_value =0 ; ik=0

	NODE : do j=1,2**nv
	wx=1.0

	 DIMENSION: do i=1,nv

	 if( ichoose(i,j) ) then
	  iva(i,j) = itop(i)
	  wx=wx*wt(i)
	 else
	  iva(i,j) = ibase(i)
	  wx=wx*wb(i)
	 endif

	 enddo DIMENSION

	 if( wx > 0 ) then
	 ik=ik+1
	 k = ilui(iva(1,j))

	 A_vt  = cuva(k) 
	 E_vt  = cery(0,k) + cery(1,k)*o3x(1) + cery(2,k)*o3x(2)+ cery(3,k)*o3x(3)
	 swx       = swx  +               wx

	 A_value      = A_value + A_vt * wx
	 E_value      = E_value + E_vt * wx

!	print'(2I4,i10,4f10.5,10I4)',ik,j,k, A_vt,B_vt ,wx,swx,iva(1:nv,j)
!	if (swx >= 0.9999 )exit
	endif

	enddo NODE
    
	uvco%cr_uva = 100. / (A_value/swx)	    
	uvco%uva = uvco%swdn_b6 * uvco%cr_uva
	
	uvco%cr_ery = (E_value/swx)/100.  !!! CORRECTION ERY
	uvco%ery =  uvco%uvb * uvco%cr_ery !!! YES UVB  needed here!!!
	uvco%uvi = uvco%ery *40.
	return

	end subroutine uva_lut_cloudy


END MODULE UVA_CORRECTION_CLOUDY
!######################################################
MODULE WSU_LUT_INTERFACE
USE WSU_TYPEDEF ,only : uvco
USE FUOUTPUT    ,only : fos,fouv , foscc
USE FUINPUT     ,only : fi,mxac,nvx,mccx
private
public :: uvco, wsu_lut
real ,parameter :: undefined = 1.0E+36
contains
!------------------------------------
subroutine wsu_lut
USE UVB_CORRECTION , only :  uvco,uvb_lut
USE UVA_CORRECTION , only :  uvco,uva_lut

USE UVB_CORRECTION_CLOUDY , only :  uvco,uvb_lut_cloudy
USE UVA_CORRECTION_CLOUDY , only :  uvco,uva_lut_cloudy
implicit none

! Had to revert to pulling these numbers out of an internal Commonblock
common /aer_inity/ a_tau2,a_ssa2,a_asy2
real ,dimension(nvx,10,mxac) :: a_tau2,a_ssa2,a_asy2

real hk1,fk1o3,sol_spect,fk1h2o
common /band1/ hk1(10), fk1o3(10),sol_spect(0:7),fk1h2o(10)

integer i,j,kk,ic,iprs
real co3,po3_b50,co3_a50
real dp,o3bar,tauabs6,u0correct
real tcf,cf1,fup1,fdn1,dir1,dif1
real tmp(3)

u0correct = fi%u0 * ( fi%ss/ sol_spect(0) ) 

! Ozone and Percent Ozone Below 20km Integration
co3 =0.0 
do i = 1,fi%nv
 dp  =(fi%pp(i+1)-fi%pp(i))
 o3bar=(fi%po(i)+fi%po(i+1)) *0.5
 co3=co3+(1.02*o3bar * dp)*466*1000.
 if ( fi%pp(i+1) < 55 )  co3_a50=co3 !! USE 55 mb as aprox for 20km..
enddo
po3_b50 = 100.*(co3-co3_a50) /co3

!! Determine Absorption Aerosol Optical Depth in Band 6 UVA surrogate
tauabs6 =0 
do i = 1,fi%nv
do j = 1,fi%nac
tauabs6 = tauabs6 + a_tau2(i,6,j)* (1.0- a_ssa2(i,6,j) )
enddo ; enddo

!print*,'uv [---------------------LUT INPUTS-------------------------------------]' &
!,'   [---------------------LUT Outputs------------------------] '
!print*,' uvFuband5 Fuband6   O3Du      u0   Sfcalb  O3%b20km AbsAOT cldtau cldhgt'&
!,'   RUVA/B6   UVA     RUVB/B5   UVB    REry/UVB   Ery  UV-Index'


fouv(1:4)%toa_uva =   83.457 *  u0correct
fouv(1:4)%toa_uvb =   18.022 *  u0correct
fouv(1:4)%toa_par =  455.230 *  u0correct

tcf = sum( fi%fc(1:mccx)%cldfrac ) !! Total Cloud Fraction (0-1)

uvco%o3       = co3	     !! O3 DU 
uvco%u0       = fi%u0     ! CosSol		
uvco%p03_20km = po3_b50   !% Percent O3 Below 20km


! Clear(kk=1) ,Pristine(kk=3) Cases...
NONCLD: do kk =1,3,2

if (kk == 1 ) uvco%tauabs = tauabs6  ! Absorption optdepth tauaer_nband6*(1-ssa)
if (kk == 3 ) uvco%tauabs = 0.00  !! NO AOT PRISTINE CASES

fup1 = sum(fos(kk)%rswfu(fi%nv+1,5:6))
fdn1 = sum(fos(kk)%rswfd(fi%nv+1,5:6))
uvco%salb = 0.0 !! Set to 0 in case no flux dn
if ( fdn1 > 0 ) uvco%salb     = fup1 / fdn1 
 
uvco%swdn_b5 = fos(kk)%rswfd(fi%nv+1,5) !! BAND 5 FU SW DN
uvco%swdn_b6 = fos(kk)%rswfd(fi%nv+1,6) !! BAND 6 FU SW DN

!.....order is important!
 call uvb_lut
 call uva_lut

!!print'(a4,20f8.3)','uvco' ,uvco  !! DEBUG PRINT CLEAR

fouv(kk)%uva     =  uvco%uva
fouv(kk)%uvb     =  uvco%uvb
fouv(kk)%uvindex =  uvco%uvi

enddo NONCLD
!-----------------------------------------------

iprs=1
CLDY: do kk =2,4,2

fouv(kk)%uva	   =  fouv(kk-1)%uva     * (1.0-tcf)
fouv(kk)%uvb     =  fouv(kk-1)%uvb     * (1.0-tcf)
fouv(kk)%uvindex =  fouv(kk-1)%uvindex * (1.0-tcf)

if (kk == 2 ) uvco%tauabs = tauabs6  ! Absorption optdepth tauaer_nband6*(1-ssa)
if (kk == 4 ) uvco%tauabs = 0.00  !! NO AOT PRISTINE CASES

CLDCND: do ic = 1,mccx
cf1 = fi%fc(ic)%cldfrac
if ( cf1 > 0.00 .and.  cf1 <= 1.001 ) then
 uvco%cldhgt =   8.0* log( fi%pp(fi%fc(ic)%icld_bot(1)) ) / log(fi%pp(fi%nv+1) )  ! ~HypsEqn
 uvco%cldtau =   fi%fc(ic)%tau_vis(1)  

if (kk == 2 ) iprs = 1
if (kk == 4 ) iprs = 2

uvco%swdn_b5 = foscc(ic,iprs)%rswfd(fi%nv+1,5) !! BAND 5 FU SW DN
uvco%swdn_b6 = foscc(ic,iprs)%rswfd(fi%nv+1,6) !! BAND 6 FU SW DN

fup1 = sum(foscc(ic,iprs)%rswfu(fi%nv+1,5:6))
fdn1 = sum(foscc(ic,iprs)%rswfd(fi%nv+1,5:6))
uvco%salb = 0.0 !! Set to 0 in case no flux dn
if ( fdn1 > 0 ) uvco%salb     = fup1 / fdn1 ! UV Surface Albedo Cloudy Sky

if ( uvco%cldtau >= 1.0 ) then
 call uvb_lut_cloudy
 call uva_lut_cloudy
elseif ( uvco%cldtau > 0.01 .and. uvco%cldtau < 1.0 ) then
  call uvb_lut
  call uva_lut

 tmp(1) = uvco%uva 
 tmp(2) = uvco%uvb 
 tmp(3) = uvco%uvi 

 call uvb_lut_cloudy
 call uva_lut_cloudy

 uvco%uva =  tmp(1)* (1.0 - uvco%cldtau) + uvco%uva *uvco%cldtau
 uvco%uvb =  tmp(2)* (1.0 - uvco%cldtau) + uvco%uvb *uvco%cldtau
 uvco%uvi =  tmp(3)* (1.0 - uvco%cldtau) + uvco%uvi *uvco%cldtau
else
 call uvb_lut
 call uva_lut
endif


fouv(kk)%uva     =  fouv(kk)%uva     + uvco%uva*cf1
fouv(kk)%uvb     =  fouv(kk)%uvb     + uvco%uvb*cf1
fouv(kk)%uvindex =  fouv(kk)%uvindex + uvco%uvi*cf1


!!print'(a4,20f8.3)','uvCO' ,uvco  !! DEBUG PRINT CLOUDY

endif
enddo CLDCND

enddo CLDY

!!! Spectral Direct/Diffuse  ratios for each sky condition..

do kk = 1,4
fouv(kk)%par     =  sum( fos(kk)%rswfd(fi%nv+1,8:10) )   !!fsfc(kk)%swpar

dir1 = fos(kk)%rswdir(fi%nv+1,5)
dif1 = fos(kk)%rswdif(fi%nv+1,5)
fouv(kk)%uvb_rdirdif = undefined
if (dif1 > 0 ) fouv(kk)%uvb_rdirdif = dir1/ dif1  !~UVB  Direct / Diffuse

dir1 =	fos(kk)%rswdir(fi%nv+1,6)
dif1 =	fos(kk)%rswdif(fi%nv+1,6)
fouv(kk)%uva_rdirdif = undefined
if (dif1 > 0 )fouv(kk)%uva_rdirdif = dir1 / dif1 !~UVA  Direct/Diffuse

dir1 = sum(fos(kk)%rswdir(fi%nv+1,8:10) )
dif1 =	sum(fos(kk)%rswdif(fi%nv+1,8:10) )
fouv(kk)%par_rdirdif = undefined
if (dif1 > 0 )fouv(kk)%par_rdirdif = dir1 / dif1 !~PAR  Direct/ Diffuse

fouv(kk)%actinic = -9.99 !!PLACE HOLDER
enddo


end subroutine wsu_lut


END MODULE WSU_LUT_INTERFACE
!#########################################################################
subroutine test_uvcorr
! This Subroutine for standalone testing.
USE WSU_LUT_INTERFACE , only :  uvco,wsu_lut
print*,'[---------------------LUT INPUTS-------------------------------------]' &
,'   [---------------------LUT Outputs------------------------] '
print*,'Fuband5 Fuband6   O3Du      u0   Sfcalb  O3%b20km AbsAOT cldtau cldhgt'&
,'   RUVA/B6   UVA     RUVB/B5   UVB    REry/UVB   Ery  UV-Index'


do icld = 0,1
 uvco%cldtau =0
if ( icld == 1) uvco%cldtau =10

do is = 5,10 ,5
do iu=100,600,100

uvco%swdn_b5 = 0.8  !! Fu Sw Sfc Dn Band5 Flux
uvco%swdn_b6 = 9.0 !! Fu Sw Sfc Dn Band6 Flux

uvco%u0       = is*.1 ! CosSol ( 0. -1. )
uvco%salb     = 0.25  ! UV Surface Albedo (0.-1.)
uvco%p03_20km = 50.   !Percent O3 Below 20km
uvco%tauabs   = 0.05  ! Absorption optdepth tauaer_nband6*(1-ssa)
uvco%o3	= iu*1.0	   ! O3 DU (200.-600.)

call wsu_lut

print'(9f8.2,1x,2f8.2,2x,2f8.2,2x,2f8.3,f8.1)',uvco
enddo
enddo
enddo
end subroutine test_uvcorr
!===================================
!call test_uvcorr
!end
